The spring extends by x on loading, then energy stored by the spring is (if T is the tension in spring and k spring constant).