Asia Hong Kong Online Preliminary

Start

2016-09-10 07:00 CEST

Asia Hong Kong Online Preliminary

End

2016-09-10 12:30 CEST
The end is near!
Contest is over.
Not yet started.
Contest is starting in -497 days 4:20:37

5:30:00

0:00:00

Problem AA+B Problem

Given $N$ integers in the range $[-50\, 000, 50\, 000]$, how many ways are there to pick three integers $a_ i$, $a_ j$, $a_ k$, such that $i$, $j$, $k$ are pairwise distinct and $a_ i + a_ j = a_ k$? Two ways are different if their ordered triples $(i, j, k)$ of indices are different.

Input

The first line of input consists of a single integer $N$ ($1 \leq N \leq 200\, 000$). The next line consists of $N$ space-separated integers $a_1, a_2, \dots , a_ N$.

Output

Output an integer representing the number of ways.

Sample Input 1 Sample Output 1
4
1 2 3 4

4

Sample Input 2 Sample Output 2
6
1 1 3 3 4 6

10