This question already has an answer here:
We have the formula for elastic energy stored in a spring to be 1/2*Force*extension. When we have an object on a vertical spring, then the energy gained should be 1/2*mgh.(h is extension produced) The loss of Potential energy by the mass seems to be mgh. But shouldn't loss of potential energy by that object equal gain in elastic potential energy? Here, only half of original Potential energy is converted to elastic potential energy. Where did the rest of energy go?