#include <bits/stdc++.h>
using namespace std;
int main() {
  long long i, a, s, d, otv = 0;
  cin >> a;
  map<long long, long long> ch;
  map<long long, long long>::iterator ii;
  vector<long long> dva;
  for (i = 0; i < a; i++) {
    cin >> d;
    ch[d]++;
  }
  d = 1;
  for (i = 0; i < 62; i++) {
    dva.push_back(d);
    d *= 2;
  }
  dva.push_back(d);
  for (ii = ch.begin(); ii != ch.end(); ii++) {
    long long kk = 0;
    kk = 0;
    for (i = 0; i < dva.size(); i++) {
      long long oo;
      oo = dva[i];
      oo -= ii->first;
      if (oo != ii->first)
        if (ch[oo] == 0)
          ch.erase(oo);
        else {
          kk = 1;
        }
    }
    for (i = 0; i < dva.size(); i++)
      if (kk == 0)
        if (dva[i] - ii->first == ii->first) {
          if (ii->second == 1) {
            otv++;
            kk = 1;
            break;
          }
          kk = 1;
        }
    if (kk == 0) {
      otv += ii->second;
    }
  }
  cout << otv;
}
