I have a function $$W(x_1,x_2,...,x_n)=A\sum_{i=1}^{n}x_i^2+\sum_{i\ne j}^{n}x_ix_j,$$ where $A \in[0,1)$. And in a paper I am reading, $W$ can be written in the "mean-variance" form:$$n(n+A-1)[\mu^2(x)-K*var(x)],$$ where $K=\frac{1-A}{n+A-1}$, $\mu$ is the mean of $x_i$'s, $var(x)=\frac{\sum_{i=1}^{n}(x_i-\mu)^2}{n}$.
How to derive the mean-variance form of the first equation? I googled and mostly mean-variance function is used in portfolio selection, here $W$ is also about the mean and dispersion of some numbers $x_i$'s. Any suggestion? Thanks in advance.