#include <bits/stdc++.h>
using namespace std;
const int max_n = 200111, inf = 1000111222;
vector<long long> v;
int main() {
  multiset<long long> s;
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    v.push_back(a);
    s.insert(a);
  }
  long long del = 0;
  for (int i = 0; i < n; ++i) {
    s.erase(s.find(v[i]));
    bool f = 0;
    for (long long pow2 = 2; pow2 <= 6e9; pow2 *= 2) {
      long long other = pow2 - v[i];
      if (s.find(other) != s.end()) {
        f = 1;
        break;
      }
    }
    if (f == 1) {
      s.insert(v[i]);
    } else {
      ++del;
    }
  }
  cout << del;
  return 0;
}
