#include <bits/stdc++.h>
int n;
long long a[120005];
struct poi {
  int cs;
  long long x;
} hash[4000007 + 5];
int has(long long x) {
  int j = x % 4000007;
  while (hash[j].cs) {
    if (hash[j].x == x) return j;
    j = (j + 1) % 4000007;
  }
  return j;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    int j = has(a[i]);
    hash[j].x = a[i];
    hash[j].cs++;
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int k = (int)log(a[i]) / log(2);
    for (int j = k + 1; j <= 31; j++) {
      long long goal = 1 << (j - 1);
      if (goal > a[i]) {
        long long mu = goal - a[i];
        if (mu == a[i]) {
          int j = has(mu);
          if (hash[j].cs >= 2) {
            ++ans;
            break;
          }
        } else {
          int j = has(mu);
          if (hash[j].cs) {
            ++ans;
            break;
          }
        }
      }
    }
  }
  printf("%d", n - ans);
  return 0;
}
