I am asked to prove that the Friedman statistic has two equivalent forms, namely:
$$ \Large \begin{aligned} S &= \frac{12n}{k(k+1)}\sum_{j=1}^k\left(R_{.j}-\frac{k+1}{2}\right)^2\\ &= \left[\frac{12}{nk(k+1)}\sum_{j=1}^kR_j^2\right]-3n(k+1) \end{aligned} $$
This is my attempt at a solution starting from LHS and trying to arrive at RHS. I feel like there are some cancellations of terms I should be aware of. Any help is appreciated. Thanks.