0197. A + B = C
Имя входного файла: | abc.in |
Имя выходного файла: | abc.out |
Ограничение по времени: | 500 ms |
Ограничение по памяти: | 32 megabytes |
You are given an array A[1…N] of different integer numbers (all of its elements do not exceed 15⋅ 106 by their absolute value). Your task is to calculate the number of different triples (p,q,r), such that A[p] + A[q] = A[r] and p, q and r are different. Note that triples (1,2,3) and (2,1,3) are considered to be different.
Input file
The first line of input file contains positive integer N (0<N<3501). The next line consists of the numbers A[1], A[2], …, A[N] separated by spaces.
Output file
Write the only number – answer to this problem.
Examples:
abc.in | abc.out |
---|---|
4 3 2 4 1 | 4 |
Источник: Petrozavodsk Summer 2003. Saratov SU Contest, Wednesday, August 27
Обсудить Отправить решение
Версия для печати