#include <bits/stdc++.h>
using namespace std;
const int N = 100002;
const int logN = 22;
vector<int> c;
map<int, int> m;
void solve() {
  int n;
  cin >> n;
  while (n--) {
    int x;
    cin >> x;
    m[x]++;
  }
  int ans = 0;
  for (const pair<int, int> &x : m) {
    bool f = false;
    for (const int &y : c) {
      if (y == x.first) {
        if (x.second >= 2) {
          f = true;
          break;
        }
        continue;
      }
      if (y != 2 * x.first && m.find(y - x.first) != m.end()) {
        f = true;
        break;
      }
    }
    if (!f) {
      ans += x.second;
    }
  }
  cout << ans << endl;
}
int main() {
  int t = 1;
  for (int i = 0; i <= 31; i++) {
    c.push_back(1 << i);
  }
  while (t--) {
    solve();
  }
  return 0;
}
