#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i, t, j, u, ct = 0;
  vector<long long> v, p;
  map<long long, long long> m;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> t;
    v.push_back(t);
    if (m[t])
      m[t]++;
    else
      m[t] = 1;
  }
  t = 2;
  for (i = 0; i < 30; i++) {
    p.push_back(t);
    t *= 2;
  }
  for (i = 0; i < n; i++) {
    u = 0;
    for (j = 0; j < 30; j++) {
      if (((p[j] - v[i] == v[i]) && m[v[i]] >= 2) ||
          ((p[j] - v[i] != v[i]) && m[p[j] - v[i]] >= 1)) {
        u = 1;
        break;
      }
    }
    if (u == 0) ct++;
  }
  cout << ct;
  return 0;
}
