This is LaTeX code:

[latex]
=p^2(p+1)\left(1+\frac{p^2-1}{2}\right)+2
[/latex]