#include <bits/stdc++.h>
using namespace std;
int N;
int Pow[40];
int A[120000 + 5];
map<int, int> vis;
multiset<int> Num;
int main() {
  Pow[0] = 1;
  for (int i = 1; i <= 31; i++) Pow[i] = Pow[i - 1] * 2;
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%d", &A[i]);
    Num.insert(A[i]);
  }
  int Ans = 0;
  for (int i = 1; i <= N; i++) {
    if (vis.count(A[i])) {
      Ans += vis[A[i]] - 1;
      continue;
    }
    bool flag = 0;
    for (int j = 0; j <= 31; j++) {
      int tmp = Pow[j] - A[i];
      int k = Num.count(tmp);
      if (tmp == A[i] && k == 1) continue;
      if (k) {
        vis[A[i]] = vis[tmp] = 1;
        flag = 1;
        break;
      }
    }
    if (!flag) {
      Ans++;
      vis[A[i]] = 2;
    }
  }
  printf("%d", Ans);
  return 0;
}
