#include <bits/stdc++.h>
using namespace std;
const int N = (int)2e5 + 5;
const int INF = (int)1e9 + 7;
int dx[8] = {1, 0, -1, 0, -1, -1, 1, 1};
int dy[8] = {0, 1, 0, -1, -1, 1, -1, 1};
int ini() {
  int x;
  scanf("%d", &x);
  return x;
}
long long inl() {
  long long x;
  scanf("%lld", &x);
  return x;
}
int a[100009], b[120009];
map<int, int> m;
map<int, bool> vis;
int main() {
  int n, i, j;
  for (i = 0; i < 30; i++) {
    a[i] = 2 << i;
  }
  n = ini();
  for (i = 1; i <= n; i++) {
    cin >> b[i];
    vis[b[i]] = true;
    if (!m[b[i]])
      m[b[i]] = 1;
    else {
      m[b[i]]++;
    }
  }
  int res = 0;
  for (i = 1; i <= n; i++) {
    bool f = true;
    for (j = 0; j < 30; j++) {
      int r = a[j] - b[i];
      if (r == b[i] && m[b[i]] > 1) {
        f = false;
        break;
      } else if (r != b[i] && m[r]) {
        f = false;
        break;
      }
    }
    if (f) res++;
  }
  cout << res << endl;
  return 0;
}
