#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
int n,i,j,k,count=0, a[100] = {0};
cin >> n;
for (i = 0; i < n; i++)
{
cin >> a[i];
}
sort(a, a + 100);
int l=0, r = n - 1;
for (j = 2; j < n; j++) {
int target = a[j];
l = 0; r = n - 1;
while (l < r)
{
if (a[l] + a[r] == target)
{
count++; r--; l++;
}
else if (a[l] + a[r] < target)l++;
else r--;
}
}
cout << count;
return 0;
}