#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> nr;
  unordered_map<long, int> sum;
  int n, i, a, num;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    for (int j = 0; j <= 30; j++) {
      num = (1 << j) - a;
      if (num < 0) continue;
      if (sum.find(num) == sum.end()) {
        if (num == a)
          sum[num] = 0;
        else
          sum[num] = 1;
      } else
        sum[num] += 1;
    }
    nr.push_back(a);
  }
  int c = 0;
  for (int i = 0; i < nr.size(); i++) {
    if (sum.find(nr[i]) == sum.end() || (sum[nr[i]] == 0)) c++;
  }
  cout << c << "\n";
  return 0;
}
