#include <bits/stdc++.h>
using namespace std;
long long power(long long b, long long e, long long m) {
  if (e == 0) return 1;
  if (e & 1) return b * power(b * b % m, e / 2, m) % m;
  return power(b * b % m, e / 2, m);
}
long long power(long long b, long long e) {
  if (e == 0) return 1;
  if (e & 1) return b * power(b * b, e / 2);
  return power(b * b, e / 2);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long i, n, num;
  map<long long, long long> m;
  vector<long long> v;
  for (i = 2; i <= (long long)2e9; i *= 2) v.push_back(i);
  cin >> n;
  for (i = 0; i < n; ++i) {
    cin >> num;
    m[num]++;
  }
  long long ans = 0;
  for (auto j : m) {
    bool found = false;
    for (auto k : v) {
      if (k > j.first) {
        if (k == 2 * j.first) {
          if (m[j.first] > 1) {
            found = true;
            break;
          }
        } else if (k > j.first && m.count(k - j.first)) {
          found = true;
          break;
        }
      }
    }
    if (!found) ans += j.second;
  }
  cout << ans;
  return 0;
}
