Since the total volume of the water is constant, the height in each vessel after interconnection will be `(h_1+h_2)/2`. The level in the left vessel shown in the ure, drops form A to C and that in the right vessel rises from B to D. Effectively, the water in the part AC has dropped down to DB.
The mass of this volume of water is
`m=rhoA(h_1-(h_1+h_2)/2)`
`rho A((h_1-h_2)/2)`
The height descended by this waster is `AC=(h_1-h_2)/2`. The work done by the force of gravity during this process is therefore,
`rhoA((h_1-h_2)/2)^2g`.