#include <bits/stdc++.h>
using namespace std;
map<int, int> ma;
int A[120000];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> A[i];
    ++ma[A[i]];
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int can = 1;
    for (int p = 1; p > 0; p <<= 1)
      if ((A[i] + A[i] != p || ma[A[i]] > 1) && ma.count(p - A[i])) {
        can = 0;
        break;
      }
    ans += can;
  }
  cout << ans << endl;
  return 0;
}
