#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e14;
int main() {
  int n;
  cin >> n;
  vector<long long> a(n + 1);
  long long maxn = -INF;
  unordered_map<long long, int> s;
  for (int i = 1; i <= n; i++)
    scanf("%lld", &a[i]), maxn = max(maxn, a[i]), s[a[i]]++;
  vector<long long> pm;
  for (int i = 0; (1ll << i) <= (maxn << 1); i++) {
    pm.push_back(1ll << i);
  }
  vector<int> cnt(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < pm.size(); j++) {
      if (pm[j] != a[i] * 2 && s[pm[j] - a[i]] > 0)
        cnt[i]++;
      else if (pm[j] == a[i] * 2 && s[pm[j] - a[i]] > 1)
        cnt[i]++;
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (cnt[i] != 0) ans++;
  }
  cout << n - ans << endl;
  return 0;
}
