#include <bits/stdc++.h>
using namespace std;
int const N = 1e6 + 100;
long long int const LINF = numeric_limits<long long int>::max();
int const INF = numeric_limits<int>::max();
int const BN = 31;
long long int gcd(long long int a, long long int b) {
  return b ? gcd(b, a % b) : a;
}
long long int pow_mod(long long int a, long long int e, long long int m) {
  long long int res = 1;
  while (e) {
    if (e & 1) res = res * a % m;
    a = a * a % m;
    e >>= 1;
  }
  return res;
}
long long int inv_mod(long long int b, long long int m) {
  b %= m;
  long long int x = 0, y = 1, r, q, a = m;
  while (b) {
    q = a / b;
    r = a % b;
    a = b;
    b = r;
    r = x;
    x = y;
    y = r - q * y;
  }
  x += m;
  return x % m;
}
int main() {
  vector<int> p2;
  long long int m = 3e9;
  long long int k = 1;
  while (k <= m) {
    p2.push_back(k);
    k <<= 1;
  }
  unordered_map<long long int, int> val;
  int n;
  cin >> n;
  vector<int> arr(n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    val[arr[i]]++;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int cnt = 0;
    for (auto x : p2) {
      if (x > arr[i]) {
        x -= arr[i];
        auto itr = val.find(x);
        if (itr != val.end()) {
          if (itr->first == arr[i]) {
            if (itr->second > 1) {
              cnt = 1;
              break;
            }
          } else {
            cnt = 1;
            break;
          }
        }
      }
    }
    ans += cnt;
  }
  cout << n - ans << endl;
}
