Since here the piston is conducting and it is moved slowly the temperature on the two sides increase and maintained at the same value.
Elementary work done by the agent work done in compress - Work done in expansion i.e. dA = p2 dV - p1dV = (p2 - p1) dV
where p1 and p2 are pressures at any instant of the gas on expansion and compression side respectively.
From the gas law p1(V0+Sx) = vRT and p2(V0 - Sx) = vRT, for each section (x is the displacement of the piston towards section 2)