#include <bits/stdc++.h>
using namespace std;
constexpr int INF = 1 << 30 - 1;
constexpr long long LLINF = 1LL << 60;
constexpr long long MOD = 1000000007;
long long pow2[41];
void makepow() {
  pow2[0] = 1;
  for (long long(i) = (0); (i) < (40); ++i) pow2[i + 1] = 2 * pow2[i];
}
map<long long, long long> mp;
bool check(vector<long long>& a, int i) {
  for (long long(j) = (0); (j) < (40); ++j) {
    long long tmp = pow2[j] - a[i];
    if (tmp == a[i] && mp[tmp] > 1) return true;
    if (tmp != a[i] && mp[tmp] > 0) return true;
  }
  return false;
}
int main() {
  makepow();
  int n;
  cin >> n;
  vector<long long> a(n);
  for (long long(i) = (0); (i) < (n); ++i) {
    cin >> a[i];
    mp[a[i]]++;
  }
  long long ans = 0;
  for (long long(i) = (0); (i) < (n); ++i) {
    if (!check(a, i)) ans++;
  }
  cout << ans << endl;
  return 0;
}
