#include <bits/stdc++.h>
using namespace std;
long long int max(long long int a, long long int b) {
  if (a < b) swap(a, b);
  return a;
}
long long int min(long long int a, long long int b) {
  if (a >= b) swap(a, b);
  return a;
}
long long int sqr(long long int p) { return p * p; }
long long int mohit(long long int a, long long int b) { return (a + b) * 2; }
long long int masahat(long long int a, long long int b) { return a * b; }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  vector<long long int> s;
  long long int n, a, c = 0, i, j, sum = 0, x[200005];
  map<long long int, long long int> map, good;
  set<long long int> pow2, el;
  cin >> n;
  s.push_back(1);
  pow2.insert(1);
  for (i = 1; i <= 31; i++) {
    s.push_back(s.back() * 2);
    pow2.insert(s.back());
  }
  for (i = 1; i <= n; i++) {
    cin >> a;
    map[a] += 1;
    if (map[a] == 1) {
      el.insert(a);
      x[++c] = a;
    }
  }
  if (n == 1)
    return cout << 1, 0;
  else {
    for (i = 1; i <= c; i++) {
      for (j = log2(x[i]) + 1; j <= 31; j++) {
        if (s[j] - x[i] == x[i] && map[x[i]] >= 2) {
          good[i] = 1;
          goto nex;
        }
        if (s[j] - x[i] != x[i] && el.find(s[j] - x[i]) != el.end()) {
          good[i] = 1;
          goto nex;
        }
      }
    nex:
      if (!good[i]) sum += map[x[i]];
    }
  }
  cout << sum;
  return 0;
}
