There is this sum: $$\sum_{i=0}^{n-1}\left(\sum_{j=i+1}^{n-1}(n-j-1)\right)=\frac{1}{6}(n-2)(n-1)n$$
I don't understand how the formula is derived. What I do currently understand is this: For each i, starting with 0 and ending with n-1 we have a sum like this: $$(n-j_{i+1}-1) + (n-j_{i+2}-1)+...+(n-j_{n-1}-1)$$ All these small sums are of course added in a grand total. For a simple case like n = 5 we have these sums: Sums computed for n = 5
I think the grand total could be expressed like this: $$\frac{(n-2)(n-1)}{2} + \frac{(n-3)(n-2)}{2}+...+1$$ but I have no clue how to get from this expression to the formula of the sum. I need a step by step proof of how this formula is derived. I don't have a formal training in math.
The innermost sum is an arithmetic progression, $$\sum_{j=i+1}^{n-1}(n-j-1)=\frac12(n-i-1)(n-i-2)\ .$$ Then you have to sum this for $i$ from $0$ to $n-1$. The most straightforward way is if you know the formulae for $\sum i$ and $\sum i^2$. Then we have $$\eqalign{\sum_{i=0}^{n-1}\frac12(n-i-1)(n-i-2) &=\frac12\sum_{i=0}^{n-1}[(n-1)(n-2)-(2n-3)i+i^2]\cr &=\frac12n(n-1)(n-2)-\frac12(2n-3)\frac12n(n-1)\cr &\qquad\qquad\qquad\qquad+\frac12\frac16n(n-1)(2n-1)\cr &=\frac1{12}n(n-1)[6(n-2)-3(2n-3)+(2n-1)]\cr &=\frac16n(n-1)(n-2)\ .\cr}$$