Initially the position of C.M. of the right side hanging mass is at L / 2n from the pulley and that of left side is at L (n - 1) / 2n from the pulley.
Therefore initially the position of C.M. of the entire chain from the pulley is at
Y1 = [(m L / 2 n2) + (m L (n - 1)2 / 2 n2) ] / m
= L (n2 - 2n + 2) / 2n2.
Finally the position of C.M. of the entire chain from the pulley is
Y2 = L / 2
There fore the work done by the gravity is
W = m g (Y2 - Y1)
= m g L ( n - 1) / n2
This work should be equal to the change in kinetic energy of the chain
m v2 / 2 = m g L ( n - 1) / n2
v = Ö (2 g L (n - 1) / n2)