#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char c;
  int ret = 0, sgn = 1;
  do {
    c = getchar();
  } while ((c < '0' || c > '9') && c != '-');
  if (c == '-')
    sgn = -1;
  else
    ret = c - '0';
  while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
  return sgn * ret;
}
map<int, int> mp;
set<int> s;
int cnt, t, n, arr[120000 + 5], m, store[50];
inline long long fast_pow(int index) {
  if (store[index]) return store[index];
  long long base = 2, ans = 1, t = index;
  while (index) {
    if (index & 1) ans *= base;
    base *= base;
    index /= 2;
  }
  return store[t] = ans;
}
int main(void) {
  n = read();
  for (int i = 1; i <= n; i++) {
    arr[i] = t = read();
    mp[t]++;
  }
  sort(arr + 1, arr + 1 + n);
  m = unique(arr + 1, arr + 1 + n) - arr - 1;
  for (int i = 1; i <= m; i++) {
    if (s.find(arr[i]) != s.end()) continue;
    bool flag = true;
    for (int index = 0, k = 0; k <= arr[m]; index++) {
      k = fast_pow(index) - arr[i];
      if (mp.find(k) != mp.end() && (k != arr[i] || mp[k] >= 2)) {
        flag = false;
        s.insert(arr[i]);
        s.insert(k);
        break;
      }
    }
    if (flag) {
      cnt += mp[arr[i]];
      mp.erase(arr[i]);
    }
  }
  cout << cnt << endl;
  return 0;
}
