#include <bits/stdc++.h>
using namespace std;
int main() {
  map<int, int> num;
  long long count = 0;
  long long arr[120005];
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> arr[i];
    num[arr[i]]++;
  }
  for (long long i = 0; i < n; i++) {
    bool check = false;
    for (long long j = 1; j < 32; j++) {
      if (num[(1 << j) - arr[i]] >= 2 ||
          num[(1 << j) - arr[i]] >= 1 && arr[i] != (1 << j) - arr[i]) {
        check = true;
        break;
      }
    }
    if (check == false) count++;
  }
  cout << count;
}
