1686 - Three Numbers

Time Limit : 1 Second

Memory Limit : 512 MB

Submission: 80

Solved: 10

Description

Give you N numbers, how many ways to choose 3 numbers A, B, C which satisfy the equation A+B+C=0?


We regard it as two distinct ways if they have different A or different B or different C.

Input

We have multiply cases. For each case:


The first line contains one number: N (0 < N <= 1000)


The second line contains N numbers, Ai, representing the above N numbers(-1e9 < Ai <1e9)

Output

For each case, output one integer, the number of ways.

sample input
4
-1 1 0 -1
3
-1 -1 2
sample output
12
6
hint

If we use the first -1, we have 6 ways: (-1 1 0), (-1 0 1), (0 1 -1), (0 -1 1), (1 0 -1), (1 -1 0);

And if we use the second -1, we have 6 ways too.

In second example, we consider two -1 is different. So there is 6 ways.

source
© 2015 HUST ACMICPC TEAM. All Right Reserved.