#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long int a[n];
  map<int, int> make_pair;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    make_pair[a[i]]++;
  }
  long long int pow2[32];
  pow2[0] = 1;
  for (int i = 1; i < 32; i++) pow2[i] = pow2[i - 1] * 2;
  sort(&a[0], &a[n]);
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 1; j < 32; j++) {
      int ind;
      ind = binary_search(a, a + n, pow2[j] - a[i]);
      if (ind) {
        if (pow2[j] - a[i] == a[i] and make_pair[a[i]] > 1) {
          cnt++;
          break;
        } else if (a[i] != pow2[j] - a[i]) {
          cnt++;
          break;
        }
      }
    }
  }
  cout << n - cnt << "\n";
  return 0;
}
