#include <bits/stdc++.h>
using namespace std;
set<long long> s;
map<long long, int> mp;
long long a[120010];
bool ok[120010];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    s.insert(a[i]);
    mp[a[i]]++;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 35; j++) {
      if ((1ll << j) > a[i] && s.find((1ll << j) - a[i]) != s.end()) {
        if (a[i] * 2ll != (1ll << j) || mp[a[i]] > 1) ok[i] = 1;
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++)
    if (!ok[i]) ans++;
  cout << ans << endl;
  return 0;
}
