#include <bits/stdc++.h>
using namespace std;
const int N = 120000 + 7;
int ar[N], n;
unordered_map<int, int> mp;
long long az[50];
int main(int argc, char const *argv[]) {
  az[0] = 1;
  for (int i = 1; i <= 32; ++i) {
    az[i] = az[i - 1] << 1;
  }
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &ar[i]);
    if (mp.count(ar[i])) {
      mp[ar[i]] = 2;
    } else
      mp[ar[i]] = 1;
  }
  if (n == 0) {
    printf("0\n");
    return 0;
  } else if (n == 1) {
    printf("1\n");
    return 0;
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int flag = 0;
    for (int j = 0; j < 32 && flag == 0; ++j) {
      int tmp = az[j] - ar[i];
      if (mp.count(tmp)) {
        if (tmp == ar[i]) {
          if (mp[ar[i]] == 2) flag = 1;
        } else
          flag = 1;
      }
    }
    if (flag == 0) ans++;
  }
  printf("%d\n", ans);
  return 0;
}
