There are N distinct points marked on a line. Point i sits at position Xi.
Pick three of the N points and call the leftmost one a, the middle one b, and the rightmost one c, at positions Xa, Xb, and Xc. The three points are evenly spaced when the distance between a and b equals the distance between b and c, that is, when Xb−Xa=Xc−Xb.
Here is an example with N=5.

The points sit at -4, -1, 0, 2, and 4. Taking -4, -1, 0 as a, b, c gives Xb−Xa=3 and Xc−Xb=1, so the spacing is not equal. Taking -4, -1, 2 gives Xb−Xa=3 and Xc−Xb=3, so those three points are evenly spaced. In this example the evenly spaced triples are (-4, -1, 2), (-4, 0, 4), and (0, 2, 4), so there are 3 of them.
Given the positions of the N points, write a program that counts how many evenly spaced triples there are.