#include <bits/stdc++.h>
const long double PI = acos(-1.0);
const long double eps = 0.000001;
using namespace std;
int n, m, ans;
long long x, a[222222];
vector<int> v;
map<long long, int> M;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%I64d", &a[i]), ++M[a[i]];
  for (int i = 1; i <= n; ++i) {
    int f = 0;
    for (long long j = 0; j <= 32; ++j)
      if ((1LL << j) > a[i]) {
        long long t = (1LL << j) - a[i];
        if (M.find(t) != M.end()) {
          if (t == a[i] && M[t] > 1) {
            f = 1;
            break;
          } else if (t != a[i] && M[t] > 0) {
            f = 1;
            break;
          }
        }
      }
    if (!f) M[a[i]] = 0, ++ans;
  }
  printf("%d\n", ans);
  return 0;
}
