#include <bits/stdc++.h>
using namespace std;
long long int binarySearch(long long int arr[], long long int l,
                           long long int r, long long int x) {
  if (r >= l) {
    long long int mid = l + (r - l) / 2;
    if (arr[mid] == x) return mid;
    if (arr[mid] > x) return binarySearch(arr, l, mid - 1, x);
    return binarySearch(arr, mid + 1, r, x);
  }
  return -1;
}
int main() {
  long long int n;
  cin >> n;
  long long int a[n], i, temp = 2, j, flag = 0, ans = 0;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  vector<long long int> v;
  for (i = 0; i < 60; i++) {
    v.push_back(temp);
    temp *= 2;
  }
  for (i = 0; i < n; i++) {
    flag = 0;
    for (j = 0; j < 60; j++) {
      if (a[i] < v[j]) {
        long long int index = binarySearch(a, 0, n - 1, v[j] - a[i]);
        if (index != -1 && index != i) {
          flag = 1;
          break;
        } else if (index == i) {
          if ((a[i - 1] == a[i]) && i - 1 >= 0) {
            flag = 1;
            break;
          }
          if ((a[i + 1] == a[i]) && i + 1 < n) {
            flag = 1;
            break;
          }
        }
      }
    }
    if (flag == 0) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
