#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> nums(n);
  unordered_map<long long, set<int>> matches;
  for (int i = 0; i < n; ++i) {
    cin >> nums[i];
    matches[nums[i]].insert(i);
  }
  int total = 0;
  for (int i = 0; i < n; ++i) {
    bool hasMatch = false;
    for (long long j = 0; j < 32; ++j) {
      long long pot = (1LL << j);
      if (nums[i] < pot) {
        long long target = pot - nums[i];
        if (matches.count(target)) {
          if (!matches[target].count(i) || matches[target].size() > 1) {
            hasMatch = true;
            break;
          }
        }
      }
    }
    if (!hasMatch) {
      ++total;
      matches[nums[i]].erase(i);
    }
  }
  cout << total << endl;
  return 0;
}
