Why is the gravitational potential energy lost not subtracted from the required work done in the given problem? 
An elastic string of natural length $l \;\text{m}$ is suspended from a fixed point $O$. When a mass of $M \;\text{kg}$ is attached to the other end of the string, its extension is $\frac {l}{10} \;\text{m}$. Some work is done to produce an additional extension of $\frac{l}{10} \;\text{m}$. Show that the work done in producing this additional extension is $\frac{3Mgl}{20} \;\text{J}$.


My Attempt. I tried to apply the work-energy principle which says that the change in total energy of an object equals the work done on it. So, the required work done should be the elastic potential energy (EPE) gained minus the gravitational potential energy (GPE) lost, which gives unmatched $\frac{Mgl}{20} \;\text{J}$. Later, I found out that if I simply ignore the GPE I will get the desired answer. But why the GPE can be ignored? Isn't the additional GPE loss got stored in the EPE?

Comment. It is a high school mechanics problem, so please do not over-complicate things. Thank you in advance.
 A: You are calculating the EPE as if there is no tension in the string before it is stretched from extension $\frac l {10}$ to extension $\frac l {5}$. But we know there is already tension $Mg$ In the string, and so the EPE initially stored in the string is $\frac {Mgl}{20}$.
The additional energy stored in the string by stretching it a further distance $\frac l{10}$ is
$\displaystyle \text {EPE}\left(\frac l 5\right) - \text {EPE}\left(\frac l {10}\right)
\\ = 4 \times \text {EPE}\left(\frac l {10}\right) - \text {EPE}\left(\frac l {10}\right) = 3 \times \text {EPE}\left(\frac l {10}\right) = \frac {3Mgl}{20}$
Another way of looking at this is to see that the mass has a lower gravitational PE at the end of the stretching, but this difference in gravitational PE is not lost - it is stored as an additional EPE of $\frac {Mgl}{10}$ on top of the work $\frac {Mgl}{20}$ done to further stretch the string. So two thirds of the extra EPE in the string comes from the work done by gravity and one third comes from the extra force required to further stretch the string.
A: You are 100 percent correct when you say that additional GPE loss got stored in EPE and actually the question requires you to only calculate this change i.e. from initial $l/10$ extension to additional $l/10$ extension.
Just consider the EPE initially for an extension of $l/10$. This will give you a value $Mgl/20 \text{J}$.
Now consider further extension of $l/10$ (so total $l/10 + l/10 =l/5$).
With total extension of $l/5$, now the final EPE will come out to be $Mgl/5 \text{J}$.
Finally the change between the final EPE and the initial EPE ($Mgl/5-Mgl/20$)$\text{J}$ which will give you $3Mgl/20 \text{J}$ as the desired answer. We are not ignoring the GPE. It is already taken into account when we calculate EPEs for both the final as well as the initial  string extensions.
Hope it clarifies.
A: The issue here is that energy of the spring-mass system is not conserved. The initial state of the system is the mass at rest and attached to the unstretched spring. If we release it, the mass will begin to gain kinetic energy and oscillate. It will never reach the final state of equilibrium where $mg=kx$. Therefore you cannot say that all of the gravitational potential energy goes into elastic potential energy. Work must be done by an external agent to bring the mass back to rest to reach the final state.
