Value of $S$ in a polygon Consider $A_1A_2A_3\dots A_n$ regular polygon is inscribed  in circle with $r$ radius. I want to find $S$ versus $r$ and angles if needed.
\begin{align}
S = & (A_1A_2 + A_1A_3 +A_1A_4 + \dots+ A_1A_n) \\
& {} +  (A_2A_3 + A_2A_4 +A_2A_5 + \dots + A_2A_n)+\dots +A_{n-1}A_n
\end{align}
Note : $A_1A_2, A_2A_3 ,\dots ,A_{n-1}A_n$ are sides of polygon and $A_1A_3, A_1A_4,\dots$ are diagonals of it.
I tried many ways but didn't get result. 
Please Help!
 A: OK, so we want to find the sum of all sides and all diagonals of a regular $n$-gon with circumradius $r$. How do we go about that?
First, what is the length of the side (say, $A_1A_2$)? It subtends an angle of $2\pi\over n$, so by the law of cosines $A_1A_2=\sqrt{r^2+r^2-2r^2\cos{2\pi\over n}}=2r\sin{\pi\over n}$. By similar reasoning, the length of the smallest diagonal $A_1A_3=2r\sin{2\pi\over n}$, then comes $A_1A_4=2r\sin{3\pi\over n}$, etc.
Now how many of each kind of diagonals are there? Again, that's simple: we have a set of $A_iA_j$ with both indexes running from 1 to $n$ (inclusive). For every fixed $i$, by varying $j$ we get each angle exactly once. Note that we've counted each chord twice (first as $A_iA_j$, then as $A_jA_i$), so we'll have to divide by 2. All in all, it is $n\cdot r\cdot\sum\limits_{i=1}^n\sin{\pi i\over n}$.
So how do we find a closed form of this? There are different approaches; one is based on representation of all these sines via complex exponents, and another is given below:
$$\sin1+\sin2+\dots+\sin n={1\over\sin{1\over2}}\left(\sin{1\over2}\sin1+\sin{1\over2}\sin2+\dots+\sin{1\over2}\sin n\right)=\\
={1\over2\sin{1\over2}}\left(\Big(\cos{1\over2}-\cos{3\over2}\Big)+\Big(\cos{3\over2}-\cos{5\over2}\Big)+\dots+\Big(\cos{2n-1\over2}-\cos{2n+1\over2}\Big)\right)=\\
={1\over2\sin{1\over2}}\left(\cos{1\over2}-\cos{2n+1\over2}\right)=
{\sin{n\over2}\sin{n+1\over2}\over\sin{1\over2}}$$
Putting all together, we have
$$S
=n\cdot r\cdot{\sin{\pi n\over2n}\sin{\pi(n+1)\over2n}\over\sin{\pi\over2n}}
=n\cdot r\cdot{\sin{\pi(n+1)\over2n}\over\sin{\pi\over2n}}
=n\cdot r\cdot{\cos{\pi\over2n}\over\sin{\pi\over2n}}
=n\cdot r\cdot\cot{\pi\over2n}$$
So it goes.
