#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  map<int, int> m;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    m[a[i]]++;
  }
  int chek[32];
  chek[0] = 2;
  for (int i = 1; i < 32; i++) {
    chek[i] = chek[i - 1] * 2;
  }
  int sm = 0, coun = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 32; j++) {
      int h = chek[j] - a[i];
      if (m.find(h) != m.end()) {
        if (h == a[i] && m[a[i]] > 1) {
          coun++;
          break;
        }
        if (h != a[i]) {
          coun++;
          break;
        }
      }
    }
  }
  cout << n - coun << endl;
  return 0;
}
