I received a question asking to determine a formula to sum the distances between all points of a regular $n$-gon inscribed in a circle of radius $1$. To solve this, I instead worked with the equivalent question of finding the sum of the distances between all distinct roots of $z^n-1$ in the complex plane. I showed that the distance between points $p$ vertices apart is $$\left|\exp\left(\frac{2\pi i p}{n}\right)-1 \right|=2\sin\left(\frac{\pi p}{n}\right)$$ I then determined how many lines connect points $p$ vertices apart and summed up these distances (this required separate formula for even and odd $n$). I then simplified the sum using $\sin(z)=\Im(e^{iz})$ and the formula for a finite geometric series. Several trig identities later, I arrived at the formula for the sum of the distances: $$n\cot\left(\frac\pi{2n}\right)$$
While the formula is surprisingly simple and elegant, my proof of it is very mechanical, requiring many trig identities, and not really giving any intuition into the final solution. Can anyone come up with other proofs of the formula?
Here is an alternative proof, though I'm not sure that it is any more intuitive. The sum of the distances from a single vertex to all vertices is $$S=\sum_{k=1}^{n}2\sin\frac{k\pi}n\ .$$ (This includes the distance to the vertex itself: as it is zero it doesn't matter whether or not we include it: it seems to be easier if we do.) To evaluate the sum we multiply by $\sin(\pi/2n)$ and use trig formulae: $$\eqalign{S\sin\frac\pi{2n} &=\sum_{k=1}^{n} 2\sin\frac{k\pi}n\sin\frac\pi{2n}\cr &=\sum_{k=1}^{n} \cos\Bigl(k-\frac12\Bigr)\frac\pi n -\cos\Bigl(k+\frac12\Bigr)\frac\pi n\cr &=2\cos\frac\pi{2n}\cr}$$ because the sum telescopes. The sum is the same for every vertex, but this will count each distance twice, so the total is $$\frac n2S=n\cot\frac\pi{2n}\ .$$