#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
  int n;
  cin >> n;
  map<long long, long long> M;
  vector<long long> v(n);
  for (int i = 0; i < (n); i++) {
    cin >> v[i];
    M[v[i]]++;
  }
  long long ans = 0;
  for (int i = 0; i < (n); i++) {
    long long x = v[i];
    for (long long o = 1; o <= 1000000000009; o <<= 1) {
      if (o > x) {
        long long u = o - x;
        if (u == x) {
          if (M[u] > 1) goto out;
        } else {
          if (M[u]) goto out;
        }
      }
    }
    ans++;
  out:;
  }
  cout << ans;
  return 0;
}
