This is inspired by the MO query here, although it has no direct implications. Below, $D$ stands for $\frac{d}{dx}$.
Define the family of polynomial functions $$f_n(x)=n^2x^{n-1}-D\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?