#include <bits/stdc++.h>
using namespace std;
int main() {
  long long MAX_C = 2147483648;
  long long MIN_C = 2;
  int n;
  cin >> n;
  int data[n];
  bool used[n];
  for (int i = 0; i < n; i++) {
    cin >> data[i];
    used[i] = false;
  }
  sort(data, data + n);
  int ret = n;
  for (int i = 0; i < n; i++) {
    if (!used[i]) {
      for (long long deg = MIN_C; deg <= MAX_C; deg *= 2) {
        long long box = deg - data[i];
        long long ind = lower_bound(data, data + n, box) - data;
        for (long long j = ind; j < n and data[j] <= box; j++) {
          if (i != j and data[j] + data[i] == deg) {
            used[i] = true;
            if (!used[j]) {
              used[j] = true;
              ret--;
            }
            ret--;
            break;
          }
        }
        if (used[i]) {
          break;
        }
      }
    }
  }
  cout << ret << endl;
  return 0;
}
