#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  long long arr[n];
  for (long long i = 0; i < n; i++) {
    cin >> arr[i];
  }
  multiset<long long> s;
  for (long long i : arr) {
    s.insert(i);
  }
  long long c = 1;
  vector<long long> a;
  for (long long i = 0; i < 50; i++) {
    if (c > 2e9 + 5) {
      break;
    }
    a.push_back(c);
    c *= 2;
  }
  long long ans = 0;
  for (long long i : arr) {
    auto it = s.find(i);
    s.erase(it);
    long long flag = 0;
    for (long long j : a) {
      if (s.find(j - i) != s.end()) {
        flag = 1;
        break;
      }
    }
    if (flag == 0) {
      ans++;
    }
    s.insert(i);
  }
  cout << ans;
  return 0;
}
