#include<iostream>
using namespace std;
#define maxn 101
int main()
{
int n;
cin >> n;
int a[maxn];
for (int i = 0; i < n; i++)
{
cin >> a[i];
}
int thispos, nextpos;
int count = 0;
for (int i = 0; i < n; i++)
{
thispos = (i+1) % n;
nextpos = (i+2) % n;
int j, k;
for (j = thispos; (j+1) % n != i; j = (j+1) % n)
{
for (k = nextpos; k % n != i ; k = (k+1) % n)
{
if (a[i] == (a[j] + a[k]))
{
count ++;
}
}
nextpos = (j + 2) % n;
}
}
cout << count;
system("pause");
return 0;
}