#include <bits/stdc++.h>
using namespace std;
map<long long, long long> vv;
map<long long, long long>::iterator it;
long long n, v[120000], hs, pt, ans;
int main() {
  scanf("%I64d", &n);
  for (long long i = 0; i < n; i++) {
    scanf("%I64d", &v[i]);
    vv[v[i]]++;
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j <= 30; j++) {
      pt = (1 << j);
      pt = pt - v[i];
      it = vv.find(pt);
      if (it != vv.end()) {
        if ((it->second) == 1 && pt == v[i]) continue;
        ans++;
        break;
      }
    }
  }
  ans = n - ans;
  printf("%I64d", ans);
  return 0;
}
