#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, ans = 0;
  cin >> n;
  long long a[n];
  map<long long, long long> mp;
  for (int i = int(0); i <= int(n - 1); i++) {
    cin >> a[i];
    mp[a[i]]++;
  }
  for (int i = int(0); i <= int(n - 1); i++) {
    for (int j = int(1); j <= int(30); j++) {
      if (a[i] < (1 << j)) {
        long long val = (1 << j) - a[i];
        if (mp.count(val) && (mp[val] > 1 || (mp[val] == 1 && val != a[i]))) {
          ans++;
          break;
        }
      }
    }
  }
  cout << n - ans << endl;
}
