Answer
Please see the work below.
Work Step by Step
We know that two forces are acting on the mass i.e the force of gravity and the force from the spring. According to Newton's second law of motion
$K\Delta y- mg=ma$
This simplifies to:
$a=\frac{K\Delta y}{m}-g$