#include <bits/stdc++.h>
using namespace std;
long long f(long long n) {
  vector<long long> v;
  while (n > 0) {
    long long k = n & (-n);
    v.push_back(n);
    n = n - k;
  }
  return v[v.size() - 1];
}
void solve() {
  long long cnt = 0, sum = 0, i, j, k;
  long long n;
  cin >> n;
  map<long long, long long> mp;
  vector<long long> v(n);
  for (long long i = 0; i < n; i++) {
    cin >> v[i];
    mp[v[i]]++;
  }
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    long long num = 1;
    bool f = 0;
    while (num <= 2e9) {
      if (mp[num - v[i]] >= 2 or
          (mp[num - v[i]] == 1 and (num - v[i]) != v[i])) {
        f = 1;
        break;
      }
      num <<= 1;
    }
    if (f == 0) ans++;
  }
  cout << ans;
}
void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int32_t main() {
  init();
  { solve(); }
  return 0;
}
