Zero quintuples
Medium
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
You are given a sequence of n distinct integers a[1]
, a[2]
, ..., a[n]
. Zero quintuple is any five numbers a[i]
, a[j]
, a[k]
, a[p]
, a[q]
(i < j < k < p < q) which sum to zero (a[i]
+ a[j]
+ a[k]
+ a[p]
+ a[q]
= 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 a[1]
, a[2]
, ..., a[n]
(-10000 ≤ a[i]
≤ 10000) - elements of the sequence.
Output
Print one integer - the number of zero quintuples in a given sequence.
Examples
Input #1
Answer #1
Submissions 366
Acceptance rate 18%