For which natural numbers $n$ is the value of the following expression a perfect square?

$$
n^{5}-n^{4}-2 n^{3}+2 n^{2}+n-1
$$
For $n=1$, the value of the given expression is 0, so $(n-1)$ can be factored out:

$$
(n-1)\left(n^{4}-2 n^{2}+1\right)
$$

The second factor of the product is a perfect square $\left(n^{2}-1\right)^{2}$, and if $n$ is a natural number, this is the square of a natural number. Thus, the product is a perfect square precisely when either the first factor is a perfect square, or the second factor is 0.

In the latter case, $|n|=1$, and thus for natural numbers, $n=1$. In the former case, $n=k^{2}+1$, where $k$ is an integer. Since choosing $k=0$ gives us the case $n=1$, the given expression is a perfect square if and only if $n=k^{2}+1$, where $k$ is an integer.