#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  map<int, int> m;
  int u = 0;
  long long powers[32];
  powers[0] = 1;
  for (int i = 1; i < 32; i++) powers[i] = 2 * powers[i - 1];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    m[a[i]]++;
  }
  bool flag = false;
  for (int i = 0; i < n; i++) {
    flag = false;
    for (int j = 0; j < 32; j++) {
      long long x = powers[j] - a[i];
      if (m[x] > 1 || (m[x] == 1 && x != a[i])) {
        flag = true;
        break;
      }
    }
    if (!flag) u++;
  }
  cout << u << endl;
  return 0;
}
