#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  unordered_map<long long, int> values;
  for (int i = 0; i != n; ++i) {
    long long val;
    cin >> val;
    values[val]++;
  }
  long long pow2[40];
  pow2[0] = 1;
  for (int i = 1; i != 31; ++i) {
    pow2[i] = pow2[i - 1] * 2;
  }
  int counter = 0;
  for (auto el : values) {
    long long val = el.first;
    bool flag = false;
    for (int i = 0; i != 31; ++i) {
      long long x = pow2[i] - val;
      if (values.find(x) != values.end()) {
        if (x != val || el.second > 1) {
          flag = true;
          break;
        }
      }
    }
    if (!flag) {
      counter += el.second;
    }
  }
  cout << counter;
  return 0;
}
