P2165 [AHOI2009] Aeroplane Chess

Description

Given several points on a circle and the arc lengths between consecutive points in circular order (each a positive integer), determine how many distinct rectangles can be formed by choosing four of these points as vertices.

Input Format

The first line contains a positive integer $N$, the number of points. Each of the next $N$ lines gives the length of the arc between consecutive points along the circle, in circular order.

Output Format

Output a single integer: the number of distinct rectangles formed.

Explanation/Hint

$N \le 20$。 ![](https://cdn.luogu.com.cn/upload/pic/13233.png) Translated by ChatGPT 5