#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  map<long long, long long> mapa;
  map<long long, bool> marcado;
  vector<long long> v, pot;
  long long n, aux, t, res = 0, l;
  bool x;
  cin >> n;
  for (int i = (0); i < (n); i++) {
    cin >> aux;
    if (mapa[aux] == 0) v.push_back(aux);
    ++mapa[aux];
    ++res;
  }
  for (long long i = 2; i <= 10e9; i *= 2) pot.push_back(i);
  l = ((int)pot.size());
  t = ((int)v.size());
  for (int i = (0); i < (t); i++) {
    for (int j = (0); j < (l); j++) {
      if (pot[j] - v[i] != v[i] && mapa[pot[j] - v[i]] > 0) {
        res -= mapa[v[i]];
        break;
      } else if (pot[j] - v[i] == v[i] && mapa[pot[j] - v[i]] > 1) {
        res -= mapa[v[i]];
        break;
      }
    }
  }
  cout << res << '\n';
  return 0;
}
