#include <bits/stdc++.h>
using namespace std;
vector<long long int> v;
long long int a[120100], n, dd;
map<int, int> mp;
int main() {
  for (long long int i = 1; i <= 2000000000; i *= 2) {
    v.push_back(i);
  }
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
    mp[a[i]]++;
  }
  sort(a, a + n);
  int f, res = 0;
  for (int i = 0; i < n; i++) {
    f = 0;
    for (int j = 0; j < v.size(); j++) {
      if (v[j] <= a[i]) continue;
      dd = v[j] - a[i];
      if (dd == a[i]) {
        if (mp[a[i]] >= 2) {
          f = 1;
          break;
        }
        continue;
      }
      if (mp[dd] >= 1) {
        f = 1;
        break;
      }
    }
    if (f == 0) res++;
  }
  cout << res << endl;
}
