#include <bits/stdc++.h>
using namespace std;
vector<long long> in;
long long n, ans = 0;
unordered_map<long long, int> m;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0, d; i < n; ++i) {
    cin >> d;
    ++m[d];
  }
  for (long long i = 1; i < (1ll << 31); i <<= 1) {
    in.push_back(i);
  }
  for (auto i : m) {
    bool f = true;
    for (auto j : in) {
      if (m.count(j - i.first) && i.first == j - i.first && i.second > 1 ||
          m.count(j - i.first) && i.first != j - i.first) {
        f = false;
      }
    }
    if (f) {
      ans += i.second;
    }
  }
  cout << ans;
}
