A cylinder containing 0.9 kg of ammonia has an externally loaded piston. Initially the ammonia is at 2 MPa, 180°C and is now cooled to saturated vapor at 40°C, and then further cooled to 20°C, at which point the quality is 50%. Find the total work for the process, assuming a piecewise linear variation of P versus V.