Thank you for posting your question here at brainly. I hope the answer will help you. Feel free to ask more questions here.
Below is the solution:
capacitors are connected in series
same q same V1=V/N
U1=1/2 C*(V/N)^2
U(total-1)=N*U1=C*V^2/2N
capacitors connected in parallel
same V
U2=1/2 C*V^2
U(total-2)=1/2 N*C*V^2
U(total-2)/U(total-1)= C*V^2/2N/N*C*V^2/2=>U(total-2)=N^2* U(total-1)