#include <bits/stdc++.h>
using namespace std;
const int MAXN = 120000;
const int MAXP = 30;
int d, n, A[MAXN];
map<int, int> C;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> A[i];
    ++C[A[i]];
  }
  for (int i = 0; i < n; ++i) {
    bool f = false;
    for (int j = 0; j <= MAXP; ++j) {
      int a = 1 << j;
      if (a < A[i]) {
        continue;
      }
      a -= A[i];
      map<int, int>::iterator x = C.find(a);
      if (x == C.end()) {
        continue;
      }
      if (a == A[i]) {
        if (x->second >= 2) {
          f = true;
          break;
        }
      } else {
        f = true;
        break;
      }
    }
    if (!f) {
      ++d;
    }
  }
  cout << d << endl;
  return 0;
}
