#include <bits/stdc++.h>
using namespace std;
int main() {
  int limit = 1e9 + 1e9;
  vector<int> all;
  int num = 1, i = 0;
  while (num <= limit) {
    num = 1 << i;
    if (num < 0) break;
    i++;
    all.push_back(num);
  }
  int n;
  cin >> n;
  map<int, int> mp;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    mp[a[i]]++;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int flag = 0;
    for (int j = 0; j < all.size(); j++) {
      int tmp = all[j] - a[i];
      if (mp.count(tmp) != 0) {
        if (tmp == a[i] && mp[tmp] > 1) {
          flag = 1;
          break;
        } else if (tmp != a[i]) {
          flag = 1;
          break;
        }
      }
    }
    if (flag == 0) ans++;
  }
  cout << ans;
}
