KBTU OPEN 2014 Spring
You are given a sequence of n distinct integers
an. Zero quintuple is any five numbers
aq (i < j < k < p < q) which sum to zero (
aq = 0). Find the number of distinct zero quintuples from the given sequence.
The first line contains n (5 ≤ n ≤ 2000) - number of elements in a sequence. The next line contains n distinct integers
an (-10000 ≤
ai ≤ 10000) - elements of the sequence.
Print one integer - the number of zero quintuples in a given sequence.
7 -4 2 3 -1 5 0 -2