#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  map<long long, long long> mp;
  long long n;
  cin >> n;
  long long a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    mp[a[i]]++;
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    bool ok = false;
    for (int j = 0; j < 31; j++) {
      long long it = 1 << j;
      if (it - a[i] == a[i]) {
        if (mp[it - a[i]] >= 2) {
          ok = true;
          break;
        }
      } else if (mp[it - a[i]] > 0) {
        ok = true;
        break;
      }
    }
    if (!ok) ++ans;
  }
  cout << ans << "\n";
  return 0;
}
