Problems
Zero quintuples
Zero quintuples
You are given a sequence of n distinct integers a1
, a2
, ..., an
. Zero quintuple is any five numbers ai
, aj
, ak
, ap
, aq
(i < j < k < p < q) which sum to zero (ai
+ aj
+ ak
+ ap
+ aq
= 0). Find the number of distinct zero quintuples from the given sequence.
Input
The first line contains n (5 ≤ n ≤ 2000) - number of elements in a sequence. The next line contains n distinct integers a1
, a2
, ..., an
(-10000 ≤ ai
≤ 10000) - elements of the sequence.
Output
Print one integer - the number of zero quintuples in a given sequence.
Input example #1
7 -4 2 3 -1 5 0 -2
Output example #1
2