What is the shape of the convex $n$-gon which gives the maximum of a function? Supposing that the length of every edge of the convex $n$-gon $P_1P_2$$\cdots$$P_n$ is 1, what is the shape of the $n$-gon which gives the maximum of the following function $A_n$? $$A_n=\sum_{1\le{i}\lt{j}\le{n}}|P_iP_j|^2$$
Here, $|P_iP_j|$ is the Euclidean length of the line segment from $P_i$ to $P_j$. 
I've already proved that $A_5$ reaches the maximum only if the pentagon is a regular pentagon, but I don't have any good idea for $n\ge6$. I need your help.
 A: In general a regular $n$-gon is best. We can represent the $P_i$ as complex numbers. Letting $p_i$ denote the complex number corresponding to $P_i$, we can assume without loss of generality that $\sum p_i = 0$. Then, the given expression is 
$$\sum_{i,j} |p_i - p_j|^2 = n \sum |p_i|^2 - \left|\sum p_i\right|^2 = n \sum |p_i|^2,$$
so it suffices to maximize $\sum |p_i|^2$. Now, we can write the Fourier expansion
$$(p_1, p_2, \ldots , p_n) = a_1 f_1 + a_2 f_2 + \cdots + a_{n - 1} f_{n - 1},$$
where $a_k \in \mathbb{C}$ and $f_k = \frac{1}{\sqrt{n}}(1, \zeta^k, \ldots , \zeta^{(n - 1)k})$ with $\zeta = e^{2 \pi i / n}$. We can calculate that
$$(p_2 - p_1, p_3 - p_2, \ldots , p_1 - p_n) = a_1(\zeta - 1)f_1 + a_2 (\zeta^2 - 1) f_2 + \cdots + a_{n - 1}(\zeta^{n - 1} - 1)f_{n - 1}.$$
Then we have
$$\sum_{i = 1}^{n - 1} a_i^2 |\zeta^i - 1|^2 = \sum_{i = 1}^n |p_{i + 1} - p_i|^2 = n,$$
while
$$\sum_{i = 1}^{n - 1} a_i^2 = \sum_{i = 1}^n |p_i|^2,$$
so we find that
$$\sum_{i = 1}^n |p_i|^2 \le \frac{n}{|\zeta - 1|^2},$$
and equality holds when the $P_i$ are vertices of a regular $n$-gon.
