#include <bits/stdc++.h>
using namespace std;
const long long INF = (1ll << 62) - 1;
const int M = 2e5 + 5;
long long ar[M], cnt, pw[M];
multiset<long long> st;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> ar[i];
    st.insert(ar[i]);
  }
  for (int i = 1; i <= n; i++) {
    int f = 0;
    st.erase(st.find(ar[i]));
    for (long long j = 1; j <= 1e10; j *= 2) {
      long long lagbe = j - ar[i];
      if (st.find(lagbe) != st.end()) {
        f = 1;
      }
    }
    if (f == 0) cnt++;
    st.insert(ar[i]);
  }
  cout << cnt << endl;
}
