Compute $\left (1+\frac{1}{2}+\cdots+\frac{1}{n} \right )^2+\cdots+\left (\frac{1}{n-1}+\frac{1}{n} \right )^2+\left (\frac{1}{n} \right )^2$ Compute the value of the following expression
$$\left (1+\frac{1}{2}+\cdots+\frac{1}{n}  \right )^2+\left ( \frac{1}{2}+\cdots + \frac{1}{n}\right )^2+\cdots+\left (\frac{1}{n-1}+\frac{1}{n}  \right )^2+\left (\frac{1}{n}  \right )^2$$
The answer is $\boxed{2n-\left (1+\frac{1}{2}+\cdots+\frac{1}{n}  \right )}$.
I've been trying to do it but I've been failed. Any ideas ?
Wolfram's test

We can solve this by recursion relations. Denoting the sum as $S_n$, we have,
$$ S_{n+1} = \left (1+\frac{1}{2}+\cdots+\frac{1}{n}+\frac{1}{n+1}  \right )^2+\left ( \frac{1}{2}+\cdots + \frac{1}{n} +\frac{1}{n+1}\right )^2+\cdots+\left (\frac{1}{n-1}+\frac{1}{n} +\frac{1}{n+1}  \right )^2+\left (\frac{1}{n} +\frac{1}{n+1}  \right )^2+\left (\frac{1}{n+1} \right)^2 = S_{n} +\frac {2}{n+1}(\left (1+\frac{1}{2}+\cdots+\frac{1}{n}  \right )+\left ( \frac{1}{2}+\cdots + \frac{1}{n}\right )+\cdots+\left (\frac{1}{n-1}+\frac{1}{n}  \right )+\left (\frac{1}{n}  \right ))+\sum_{k=1}^{n} \left (\frac{1}{n+1} \right)^2 +\left (\frac{1}{n+1} \right)^2 = S_{n} + \frac{2n+1}{n+1} $$
So, we have $$S_{n} - S_{n-1} = \frac {2n-1}{n}=2-\frac{1}{n}$$
Where from we get,
$$S_{n}-S_{1} = 2n - 1 -\left (1+\frac{1}{2}+\cdots+\frac{1}{n}  \right )$$
But $S_{1} = 1$. So,
$$S_{n} = 2n  -\left (1+\frac{1}{2}+\cdots+\frac{1}{n}  \right )$$
