Hide

Problem Q
A+B Problem

Given N integers in the range [50000,50000], how many ways are there to pick three integers ai, aj, ak, such that i, j, k are pairwise distinct and ai+aj=ak? 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 (1N200000). The next line consists of N space-separated integers a1,a2,,aN.

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
Hide

Please log in to submit a solution to this problem

Log in