#include <bits/stdc++.h>
using namespace std;
long long two[63];
int main() {
  map<long long, long long> mp;
  long long n, i, ind, p, j, k, s, ans = 0, temp;
  scanf("%lld", &n);
  long long ara[n];
  for (i = 0; i < n; i++) {
    scanf("%lld", &ara[i]);
    mp[ara[i]]++;
  }
  sort(ara, ara + n);
  for (i = 1; i <= 62; i++) {
    two[i] = pow(2, i);
  }
  for (i = 0; i < n; i++) {
    p = ara[i];
    temp = 0;
    for (j = 1; j <= 62; j++) {
      s = two[j];
      ind = lower_bound(ara, ara + n, s - p) - ara;
      if (ind == n || ara[ind] != s - p ||
          (ara[ind] == s - p && p == s - p && mp[s - p] <= 1)) {
        continue;
      } else {
        temp = 1;
      }
    }
    if (temp == 0) {
      ans++;
    }
  }
  printf("%lld", ans);
}
