#include <bits/stdc++.h>
using namespace std;
const int maxn = 120009;
int n, a[maxn];
vector<int> powers;
map<int, int> mp;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int p = 1;
  for (int i = 1; i <= 31; i++) {
    powers.push_back(p);
    p = p * 2;
  }
  cin >> n;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    mp[a[i]]++;
  }
  for (int i = 0; i < n; i++) {
    bool can = false;
    for (int j = 0; j < powers.size(); j++) {
      int want = powers[j] - a[i];
      if (want != a[i] && mp[want])
        can = true;
      else if (want == a[i] && mp[want] > 1)
        can = true;
    }
    if (!can) ans++;
  }
  cout << ans;
}
