#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long long n;
  cin >> n;
  vector<long long> v(n);
  map<long long, long long> mp;
  for (long long i = 0; i < n; i++) {
    cin >> v[i];
    mp[v[i]]++;
  }
  sort(v.begin(), v.end());
  long long cnt = 0;
  for (long long i = 0; i < n; i++) {
    long long val = v[i];
    bool flag = false;
    for (long long j = 0; j < 31; j++) {
      long long temp = 1LL << j;
      if (temp <= val) {
        continue;
      } else {
        temp -= val;
      }
      if (binary_search(v.begin(), v.end(), temp)) {
        if (val == temp and mp[val] == 1) {
          continue;
        }
        flag = true;
        break;
      }
    }
    if (!flag) {
      cnt++;
    }
  }
  cout << cnt << '\n';
  return 0;
}
