#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = (int)1e5 + 5;
long long int a[1000005], n, p[35];
long long int bs(long long int srch, long long int n) {
  long long int pos = -123;
  long long int Start = 0, End = n - 1;
  long long int mid = (Start + End) / 2;
  while (Start <= End && a[mid] != srch) {
    if (srch < a[mid]) {
      End = mid - 1;
    } else {
      Start = mid + 1;
    }
    mid = (Start + End) / 2;
  }
  if (a[mid] == srch) {
    pos = mid;
    return pos;
  } else {
    return pos;
  }
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  map<long long int, long long int> mp;
  p[0] = 1;
  for (long long int i = 1; i <= 32; i++) {
    p[i] = p[i - 1] * 2;
  }
  cin >> n;
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    mp[a[i]]++;
  }
  int cnt = 0;
  for (long long int i = 0; i < n; i++) {
    bool flag = false;
    mp[a[i]]--;
    for (long long int j = 0; j <= 32; j++) {
      long long int Find = p[j] - a[i];
      if (mp[Find] >= 1) {
        flag = true;
      }
    }
    mp[a[i]]++;
    if (!flag) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
