#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e6 + 10;
long long n, a[MAXN], good;
set<long long> st;
map<long long, long long> cnt;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cnt[a[i]]++;
    st.insert(a[i]);
  }
  for (int i = 0; i < n; i++) {
    long long res = 1;
    if (st.find(res - a[i]) != st.end() &&
        (res - a[i] != a[i] || ((res - a[i] == a[i]) && cnt[a[i]] > 1))) {
      good++;
      continue;
    }
    for (int step = 1; step < 60; step++) {
      res *= 2;
      if (st.find(res - a[i]) != st.end() &&
          (res - a[i] != a[i] || ((res - a[i] == a[i]) && cnt[a[i]] > 1))) {
        good++;
        break;
      }
    }
  }
  cout << n - good;
  return 0;
}
