By iteratively substituting, we have
[tex]a_n = a_{n-1} + n[/tex]
[tex]a_{n-1} = a_{n-2} + (n - 1) \implies a_n = a_{n-2} + n + (n - 1)[/tex]
[tex]a_{n-2} = a_{n-3} + (n - 2) \implies a_n = a_{n-3} + n + (n - 1) + (n - 2)[/tex]
and the pattern continues down to the first term [tex]a_1=0[/tex],
[tex]a_n = a_{n - (n - 1)} + n + (n - 1) + (n - 2) + \cdots + (n - (n - 2))[/tex]
[tex]\implies a_n = a_1 + \displaystyle \sum_{k=0}^{n-2} (n - k)[/tex]
[tex]\implies a_n = \displaystyle n \sum_{k=0}^{n-2} 1 - \sum_{k=0}^{n-2} k[/tex]
Recall the formulas
[tex]\displaystyle \sum_{n=1}^N 1 = N[/tex]
[tex]\displaystyle \sum_{n=1}^N n = \frac{N(N+1)}2[/tex]
It follows that
[tex]a_n = n (n - 2) - \dfrac{(n-2)(n-1)}2[/tex]
[tex]\implies a_n = \dfrac12 n^2 + \dfrac12 n - 1[/tex]
[tex]\implies \boxed{a_n = \dfrac{(n+2)(n-1)}2}[/tex]