Let $(x_n)$, $n=1,2, \ldots $ be a sequence defined by $x_1=2008$ and \begin{align*} x_1 +x_2 + \ldots + x_{n-1} = \left( n^2-1 \right) x_n \qquad ~ ~ ~ \forall n \geq 2 \end{align*}Let the sequence $a_n=x_n + \frac{1}{n} S_n$, $n=1,2,3, \ldots $ where $S_n$ $=$ $x_1+x_2 +\ldots +x_n$. Determine the values of $n$ for which the terms of the sequence $a_n$ are perfect squares of an integer.