I thought it would be appropriate to see how this formula comes about. There are 2 key elements to this:
$1.$ For a diagonal matrix of the from $A=aI$, for any $a$ in your base field. Every matrix obviously commutes with $A$. Therefore the dimension of the space of matrices commuting with $A$ in this case is nothing but $n^2$, if you're working over the space of $n \times n$ matrix.
$2$. Now if you have a diagonal matrix of the form $$A =
\begin{pmatrix}
a\\
&a\\
&&a\\
&&&b\\
&&&&b\\
&&&&&c
\end{pmatrix} = \begin{pmatrix}
aI_3\\
&bI_2\\
&&cI_1
\end{pmatrix}$$
(The blank spaces are $0$s and the $0-$matrix) Then any matrix commutes with $A$ if and only if it commutes with the each submatrix ($I_n$ is the identity matrix of order $n$), hence the dimension in this case is nothing but $3^2 + 2^2 + 1^2$
In our case, we have $15$ submatrices, which are $I_{15}, 2I_{14}, 3I_{13},\cdots,14I_2,15I_1$, giving us the dimension as $15^2 + 14^2 + \cdots + 3^2 + 2^2 + 1^2$
Note, if the diagonal elements of $A$ were distinct, then the only matrices commuting with $A$ would be all diagonal matrices, giving the dimension simply $n$