#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false);
  long long int n, s[31], p = 1, sum = 0, ans = 0;
  cin >> n;
  long long int a[n];
  map<long long int, long long int> mp1;
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    mp1[a[i]]++;
  }
  for (long long int i = 0; i < 31; i++) {
    s[i] = p;
    p *= 2;
  }
  for (long long int i = 0; i < n; i++) {
    long long int count = 0;
    for (long long int j = 0; j < 31; j++) {
      if (s[j] > a[i] && mp1[s[j] - a[i]] > 0) {
        if (s[j] - a[i] == a[i] && mp1[s[j] - a[i]] == 1) continue;
        count++;
        break;
      }
    }
    if (count == 0) ans++;
  }
  cout << ans << endl;
}
