#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long int a[n], i, j, k = 0, l, m, b[31], c[n], max, min, *lo;
  long long int low, high, mid;
  int sum = 0;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    c[i] = 0;
  }
  b[0] = 1;
  for (i = 1; i < 31; i++) {
    b[i] = 2 * b[i - 1];
  }
  sort(a, a + n);
  max = a[n - 1];
  min = a[0];
  for (i = 0; i < n; i++) {
    l = -1;
    for (j = 0; j < 31; j++) {
      m = b[j] - a[i];
      if (m < min) {
        continue;
      }
      if (m >= min && m <= max) {
        low = 0;
        high = n - 1;
        mid = (low + high) / 2;
        while (low <= high) {
          if (a[mid] == m) {
            l = mid;
            high = mid - 1;
          } else if (a[mid] < m) {
            low = mid + 1;
          } else {
            high = mid - 1;
          }
          mid = (low + high) / 2;
        }
        if (l == i && i < n - 1 && a[i] != a[i + 1]) {
          l = -1;
        } else if (l == i && i == n - 1) {
          l = -1;
        }
      }
      if (m > max) {
        break;
      }
      if (l != -1) {
        k++;
        break;
      }
    }
  }
  cout << n - k;
  return 0;
}
