This question is inspired by [the MO query here][1], although it has no direct implications.

Define the family of polynomial functions
$$f_n(x)=n^2x^{n-1}-\frac{d}{dx}\left(\frac{x^n-1}{x-1}\right),$$
and the associated family of algebraic functions
$$g_n(x)=\frac{\sqrt{f_n(x)}}n+\sum_{j=1}^{n-1}\frac{\sqrt{f_j(x)}}{j(j+1)}.$$

>**Question.** Despite the complicated expressions for $f_n$ and $g_n$, does 
$$h_n(x)=\sum_{k=0}^n\left(g_n(x)-g_k(x)\right)^2$$
have a neat (closed) formula? 

>**UPDATE.** user64494 (see below) has found $h_n(x)=nx^{n-1}$. Any proof?

**Convention:** $g_0:=0$ and empty sums are zero.

For example, $h_2(x)=g_2(x)^2+(g_2(x)-g_1(x))^2+(g_2(x)-g_2(x))^2=2x$.

[1]: https://mathoverflow.net/questions/260169/lower-bound-for-frac-sum-i-j-minf-i-f-j2-g-i-g-j2-sum-i-j-max