#include <bits/stdc++.h>
using namespace std;
vector<long long> v, a;
map<long long, long long> m;
int main() {
  long long n, i, j, k, q, cnt = 0;
  for (i = 1; i <= 32; i++) {
    long long p = pow(2, i);
    v.push_back(p);
  }
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> q;
    a.push_back(q);
    m[q]++;
  }
  for (i = 0; i < n; i++) {
    int flag = 0;
    for (j = 0; j < 32; j++) {
      long long f;
      if (v[j] > a[i])
        f = (v[j] - a[i]);
      else
        continue;
      if (f != a[i] || (f == a[i] && m[f] > 1)) {
        if (m[f] > 0) {
          flag = 1;
          break;
        }
      }
    }
    if (flag == 0) {
      cnt++;
    }
  }
  cout << cnt << endl;
}
