#include <bits/stdc++.h>
using namespace std;
bool comp(long long int a, long long int b) { return a < b; }
void solve() {
  int n, ans = 0;
  cin >> n;
  std::vector<int> v;
  std::map<int, int> m;
  for (int i = 0; i < n; i += 1) {
    int x;
    cin >> x;
    v.push_back(x);
    m[x]++;
  }
  for (int i = 0; i < n; i += 1) {
    bool ok = false;
    for (int j = 0; j < 31; j += 1) {
      int x = (1 << j) - v[i];
      if (m.count(x) && (m[x] > 1 || (m[x] == 1 && x != v[i]))) {
        ok = true;
      }
    }
    if (!ok) {
      ans++;
    }
  }
  cout << ans << endl;
}
int main() {
  int t;
  t = 1;
  while (t--) {
    solve();
  }
}
