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 $B_n$? $$B_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 $B_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.

This question (let's call this **B**) is related with the following question (let's call this **A**) which has been asked previously on mathoverflow without receiving any answers.

The question **A**: What is the shape of the $n$ -gon $P_1P_2$$\cdots$$P_n$ which gives the maximum of $A_n$? The quantity $A_n$ is defined by
$$A_n =\frac{∑_{i<j≤n} {∣P_iP_j ∣}^2 −∑_i^n∣P_iP_{i+1}∣^ 2}{∑_i^n∣P_iP_{i+1}∣^ 2}$$

Here, $∣P_iP_j∣$ is the Euclidean length of the line segment from $P_i$ to $P_j$. Note that $P_{n+1}=P_1$ and that the $n$-gon can be either convex or concave.

I'm interested in $A_n$ because I knew the fact that the maximum of $A_4$ is $1$ only if $P_1P_2P_3P_4$ is a parallelogram. I've already proved the case $n=4$ , but I don't have any good idea for $n\ge5$.

Could you tell me how to solve this problem? What is the shape of the $n$-gon which gives the maximum of a function?

I think I can prove that $A_5$ reaches the max only if the pentagon is a regular pentagon. Please judge whether my proof is correct or not. I use an transforming operation through which the value of $A_5$ doesn't change or increases. Here is the operation which consists of the following steps.

First, find the two adjacent edges which has the largest of $||$$P_iP_{i+1}$$|$$-$$|$$P_{i+1}P_{i+2}$$|$$|$, say $P_1P_2$ $\ge$ $P_2P_3$. Next, draw the circle $C_{13}$, the center is the midpoint $M_{13}$ of the line segment $P_1P_3$ and the radius is the line segment $M_{13}P_2$.

Next, draw the perpendicular bisector $L_{13}$ of the line segment $P_1P_3$. Final step is to determin an intersection $Q_2$ where the line $L_{13}$ crosses the circle $C_{13}$. This is the transforming operation.

The point $Q_2$ is outside of the circle $C_{45}$, the center is the midpoint $M_{45}$ of the edge $P_4P_5$ and the radius is the line segment $M_{45}P_2$. This means the following two.

$$|P_2P_1|^2+|P_2P_3|^2=|Q_2P_1|^2+|Q_2P_3|^2$$ and $$|P_2P_5|^2+|P_2P_4|^2\le|Q_2P_5|^2+|Q_2P_4|^2$$ Therefore, the $A_5$ for the pentagon $P_1Q_2P_3P_4P_5$ is larger than, or equals to the $A_5$ for the pentagon $P_1P_2P_3P_4P_5$. Note that the lengths of the other line segment is constant.

By using this transforming operation infinitely, you get the pentagon whose edges have the same length. Without loss of generality suppose that the pentagon whose edges have the same length $1$. Then, $A_5=2-\frac25W$. Here, $W=\cos A+\cos B+\cos C+\cos D+\cos E$.

$W$ is min only if the pentagon is a regular pentagon, so the proof is completed.

If we can use this transforming operation for $n$-gon, it's sufficient to solve **B** in order to solve the problem **A**. This is why I'm asking **B**.
My aim is to solve **A**. If you have a better idea to solve **A**, you don't need to solve **B**. Please teach me how to solve **A**.