I am struggling to understand the closed form calculation of the following triple summation:
$$ \sum_{i=1}^{n} \sum_{j=i+1}^{n} \sum_{k=i+j-1}^{n} 1 $$
The first step I understand:
$$ \sum_{i=1}^{n} \sum_{j=i+1}^{n} \sum_{k=i+j-1}^{n} 1=\sum_{i=1}^{n} \sum_{j=i+1}^{n}(-i-j+n+2) $$
But the next steps are what confuses me.
$$ =\sum_{i=1}^{n} \sum_{j=i+1}^{n}(-i-j+n+2)=\sum_{i=1}^{n}\left(\frac{1}{2}(i-n)(3 i-n-3)\right) $$
$$ =\frac{1}{2}(n-1) n $$
I would like to know, in excruciating detail, how $$ \sum_{j=i+1}^{n}(-i-j+n+2) = \frac{1}{2}(i-n)(3 i-n-3) $$
Let $r=j-i$, then $j=r+i$ and $$\begin{align}\sum_{j=i+1}^{n}(-i-j+n+2)&=\sum_{r=1}^{n-i}(-2i-r+n+2)\\ &=-\sum_{r=1}^{n-i}r+(n+2-2i)\sum_{r=1}^{n-i}1\\ &=-\frac{(n-i)(n-i+1)}{2}+(n+2-2i)(n-i)\\ &=\frac{(n-i)(-n+i-1+2n+4-4i)}{2}\\ &=\frac{(n-i)(n+3-3i)}{2}. \end{align}$$ which is the equal to $\frac{1}{2}(i-n)(3 i-n-3)$. As regards the last sum, let $j=n-i$, then $i=n-j$ and $$\begin{align} \sum_{i=1}^{n}\frac{(n-i)(n+3-3i)}{2}& =\frac{1}{2}\sum_{j=1}^{n-1}j(3j+3-2n)\\ &=\frac{3}{2}\sum_{j=1}^{n-1}j^2+\frac{(3-2n)}{2}\sum_{j=1}^{n-1}j\\ \end{align}$$ Can you finish the job?