#include <bits/stdc++.h>
using namespace std;
int x;
int main() {
  int n, cnt = 0;
  scanf("%d", &n);
  int a[n];
  map<int, int> m;
  for (int i = (int)0; i < (int)n; ++i) {
    scanf("%d", &a[i]);
    ++m[a[i]];
  }
  vector<long long> v(60);
  for (int i = (int)0; i < (int)60; ++i) v[i] = pow(2, i);
  bool found;
  for (int i = (int)0; i < (int)n; ++i) {
    found = 0;
    for (int j = (int)0; j < (int)60; ++j) {
      if (v[j] - a[i] <= 1000000000)
        if ((m[v[j] - a[i]] > 1) ||
            (m[v[j] - a[i]] == 1 && a[i] != v[j] - a[i])) {
          found = 1;
          break;
        }
    }
    if (found) ++cnt;
  }
  printf("%d\n", n - cnt);
  return 0;
}
