Let

be a fixed positive integer. Then

points can be equally spaced along the boundary of the unit disk in the complex plane, and their positions described in the complex plane are given by

, where

.
So, for any

, we can write

The distance between two points

and

is given by the norm of the difference of the points. We denote this by

We're interested in all the possible distinct pairings, which means

and

are to be considered the same, so to accomplish this we assume

.
Then the sum we're interested in finding is

where this sum is identical to the one in your original question, except the indices of each point are shifted down by one.
We have






So we can express the sum as

For example, if we take

points, we can see the points make up the vertices of a square with inradius 1, which means the distance between adjacent points (

) is

, while the distance between opposite points (

, which gets counted only once) is

. So we would expect the sum to be

In terms of our sum, we would add




as required.
This was just an example to convince you that the formula works.
For

, you would end up with





