#include <bits/stdc++.h>
using namespace std;
int a[120005], two[120005];
map<int, int> mp;
int main() {
  ios_base::sync_with_stdio(0);
  ;
  cin.tie(0);
  cout.tie(0);
  int i, n, j;
  two[0] = 1;
  for (i = 1; i < 31; i++) two[i] = two[i - 1] * 2;
  cin >> n;
  for (i = 0; i < n; i++) cin >> a[i], mp[a[i]]++;
  int ans = n;
  for (i = 0; i < n; i++) {
    mp[a[i]]--;
    for (j = 0; j < 31; j++) {
      if (two[j] < a[i]) continue;
      int x = two[j] - a[i];
      if (mp[x] > 0) {
        ans--;
        break;
      }
    }
    mp[a[i]]++;
  }
  cout << ans;
  return 0;
}
