import java.util.LinkedList;
import java.util.Scanner;
public class Main {
private static Scanner cin;
public static void main(String args[]) throws Exception {
cin = new Scanner(System.in);
int n = cin.nextInt();
int ret = 0;
LinkedList<Integer> list = new LinkedList<Integer>();
for (int i = 0; i < n; i++) {
list.add(cin.nextInt());
}
Integer[] array = new Integer[list.size()];
list.toArray(array);
for (int i = 0; i < array.length; i++) {
for (int j = 0; j < array.length; j++) {
if (j != i) {
for (int k = j + 1; k < array.length; k++) {
if (k != i && array[j] + array[k] == array[i]) {
ret++;
k = array.length;
j = k;
}
}
}
}
}
System.out.println(ret);
}
}