#include <bits/stdc++.h>
using namespace std;
bool isPowerOfTwo(int num) { return (num && (!(num & (num - 1)))); }
int main() {
  int n;
  cin >> n;
  int a[n];
  map<int, int> c;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    c[a[i]]++;
  }
  int res = 0;
  for (int i = 0; i < n; ++i) {
    bool ok = false;
    for (int j = 0; j < 31; ++j) {
      int diff = (1 << j) - a[i];
      if (c.count(diff) && (c[diff] >= 2 || (c[diff] == 1 && diff != a[i]))) {
        ok = true;
        break;
      }
    }
    if (!ok) {
      ++res;
    }
  }
  cout << res << endl;
  return 0;
}
