#include <bits/stdc++.h>
using namespace std;
vector<long long int> v;
vector<long long int>::iterator it, it1;
void init() {
  v.push_back(1);
  long long int z;
  for (int i = 1; i <= 42; i++) {
    z = v[i - 1] * 2;
    v.push_back(z);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  init();
  long long int i, j, k, z, cnt, n, sum = 0;
  cin >> n;
  vector<long long int> a;
  bool flag[n];
  for (i = 0; i < n; i++) {
    cin >> z;
    a.push_back(z);
    sum += z;
  }
  sort(a.begin(), a.end());
  memset(flag, 0, sizeof(flag));
  it = upper_bound(v.begin(), v.end(), sum);
  if (*it > sum) it--;
  z = *it;
  for (i = 0; i < n; i++) {
    if (!flag[i]) {
      it = upper_bound(v.begin(), v.end(), a[i]);
      if (*it == a[i]) it++;
      while (*it <= z) {
        if (binary_search(a.begin(), a.end(), *it - a[i])) {
          it1 = lower_bound(a.begin(), a.end(), (*it - a[i]));
          j = it1 - a.begin();
          if (j == i) {
            it++;
            continue;
          }
          if (j != i) {
            flag[i] = 1;
            flag[j] = 1;
            it++;
            continue;
          }
        } else
          it++;
      }
    }
  }
  cnt = 0;
  for (i = 0; i < n; i++) {
    if (!flag[i]) cnt++;
  }
  cout << cnt << endl;
  return 0;
}
