Stress = Mg/A, {Where A is the cross-sectional area of the wire} Strain = l/L.
Since the elastic potential energy
U = ½(Stress)*(Strain)*(Volume)
→U = ½*(Mg/A)*(l/L)*(AL) =½Mgl
The loss in gravitational potential energy will be Mgl only when the load is suddenly released from the initial position i.e. when elongation is zero. The elastic potential energy stored in the wire =½Mgl when the elongation is l, the rest of the gravitational potential energy Mgl-½Mgl =½Mgl is converted to the kinetic energy. At the time elongation is l, the mass M will have a certain speed say v. So ½Mv² =½Mgl
→v² = gl
→v =√(gl).
This point as a mean position the mass will be in a simple harmonic motion vertically. Slowly it will come to rest at the mean position by dissipating this energy in the form of heat.