For a system
Q =W+ ΔE
where ΔE is the change in E, the stored energy in the ΔE system.
E has various forms
1. Kinetic Energy
2. Potential Energy
Work done on system = mg(z2 - z1 )
3. Other forms of energy are due to random movement of molecules, chemical energy etc. and are combined in U, the internal energy.