#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int arr[120000];
  unordered_map<int, int> dic;
  for (int i = 0; i < n; ++i) {
    scanf("%d", arr + i);
    dic[arr[i]]++;
  }
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    bool f = 0;
    for (int j = 0; j <= 30; ++j) {
      if ((1 << j) < arr[i]) continue;
      int val = (1 << j) - arr[i];
      if (val == arr[i] && dic[(1 << j) - arr[i]] > 1 ||
          val != arr[i] && dic[(1 << j) - arr[i]])
        f = 1;
    }
    if (!f) cnt++;
  }
  printf("%d", cnt);
  return 0;
}
