#include <bits/stdc++.h>
using namespace std;
unordered_map<long long, long long> m;
int main() {
  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long long n;
  cin >> n;
  long long i, j, a[n];
  for (i = 0; i < n; i++) {
    cin >> a[i];
    m[a[i]]++;
  }
  long long p = 2, powtwo[31];
  for (i = 0; i < 31; i++) {
    powtwo[i] = p;
    p *= 2;
  }
  long long ans = 0;
  for (i = 0; i < n; i++) {
    int found = 0;
    for (j = 0; j < 31; j++) {
      if (m[powtwo[j] - a[i]]) {
        if (powtwo[j] == 2 * a[i] && m[a[i]] == 1) continue;
        found = 1;
        break;
      }
    }
    if (!found) ans++;
  }
  cout << ans;
  return 0;
}
