N points lie on a circle. Write a program that counts the distinct equilateral triangles whose three vertices are all among the given points.
The positions of the points are fixed by the arc lengths between neighboring points along the circle. In the figure below, (a) shows eight points whose consecutive arc lengths are 4, 2, 4, 2, 2, 6, 2, 2, and (b) shows the two equilateral triangles that can be built from them.
Input
The first line contains the number of points N. The second line contains N integers X1,X2,…,XN. For 1≤i≤N−1, Xi is the length of the arc between point i and point i+1, and XN is the length of the arc between point N and point 1. Points 1 through N are numbered in one direction around the circle.
Restrictions
3≤N≤105
1≤Xi≤103 for 1≤i≤N
Output
Print one line containing a single integer, the number of distinct equilateral triangles whose vertices are given points.