#include <bits/stdc++.h>
using namespace std;
const int tinf = (int)1e9 + 7;
const long long inf = (long long)1e18 + 7;
const int N = 4e5 + 5;
int main() {
  {
    ios ::sync_with_stdio(false);
    cin.tie(0);
  }
  long long n, m, a[N], ans = 0, b[100] = {};
  map<long long, long long> g;
  cin >> n;
  b[0] = 1;
  for (int i = 1; i <= 60; i++) b[i] = b[i - 1] * 2;
  for (int i = 0; i < n; i++) cin >> a[i], g[a[i]]++;
  for (int i = 0; i < n; i++) {
    long long e = 0;
    for (int j = 0; j < 35; j++)
      if ((g[b[j] - a[i]] && b[j] != a[i] * 2) ||
          (b[j] == a[i] * 2 && g[a[i]] > 1)) {
        e = 1;
        break;
      }
    if (!e) ans++;
  }
  cout << ans;
}
