#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  map<int, int> a;
  for (int i = 0, x; i < n; ++i) {
    cin >> x;
    ++a[x];
  }
  int ans = 0;
  for (auto &i : a) {
    bool flag = true;
    for (int d = 0, x; d < 32; ++d) {
      x = (1 << d) - i.first;
      if (x <= 0) {
        continue;
      }
      if (a.find(x) != a.end()) {
        if (a[x] > 1 || (a[x] > 0 && x != i.first)) {
          flag = false;
          break;
        }
      }
    }
    if (flag) {
      ans += i.second;
    }
  }
  cout << ans << endl;
  return 0;
}
