Submit solution

Points: 7
Time limit: 1.0s
Memory limit: 64M

Problem type

Given an array of integers, a, compute the number of unique ways to satisfy the equation a_i + a_j = a_k, where i \neq j \neq k and a_i \leq a_j. To be unique, each counted equation after being filled in must never have been counted before.

Input Specification

The first line will contain a single integer N, 3 \leq N \leq 5000.

The next line will contain N space separated integers, describing the array. 1 \leq a_i \leq 10^6

Output Specification

The output will contain a single line, the number of unique triples that can be formed by the array.

Sample Input

4
1 5 3 2

Sample Output

2

Explanation for Sample

The unique equations are 1 + 2 = 3 and 2 + 3 = 5


Comments

There are no comments at the moment.