If a spring of spring constant k extends by x on loading due to an applied force F, then the energy stored by the spring is
We have F=kx and U=kx22.
Therefore,
U=F22k