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