#include <bits/stdc++.h>
using namespace std;
int in() {
  int x;
  scanf("%d", &x);
  return x;
}
long long lin() {
  long long x;
  scanf("%lld", &x);
  return x;
}
int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; ++i) a[i] = lin();
  multiset<long long> st;
  for (int i = 0; i < n; ++i) st.insert(a[i]);
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    st.erase(st.find(a[i]));
    bool ok = false;
    for (int j = 0; j < 32; ++j) {
      long long s = (1LL << j);
      if (st.count(s - a[i]) >= 1) ok = true;
    }
    if (!ok) ans++;
    st.insert(a[i]);
  }
  cout << ans << endl;
  return 0;
}
