#include <iostream>
using namespace std;
int cn, n, a[512], s[512];
bool este_putere_la_doi(int x)
{
return !(x & (x - 1));
}
void c_binara(int lhs, int rhs)
{
if (lhs < rhs)
{
if (rhs - lhs == 1)
{
if (este_putere_la_doi(s[lhs]))
++cn;
}
else
{
int jum = (lhs + rhs) / 2;
c_binara(lhs, jum);
c_binara(jum, rhs);
}
}
}
int main()
{
cin >> n;
for (int i = 0; i < n; ++i)
cin >> a[i];
for (int i = 0; i < n - 1; ++i)
for (int j = i + 1; j < n; ++j)
s[cn++] = a[i] + a[j];
n = cn;
cn = 0;
c_binara(0, n);
std::cout << cn;
}