#include <bits/stdc++.h>
using namespace std;
int binarySearch(int arr[], int l, int r, int x) {
  if (r >= l) {
    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() {
  int n, i, a[200005], j;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a, a + n);
  int power[2000];
  power[0] = 1;
  for (i = 1; i < 32; i++) {
    power[i] = power[i - 1] * 2;
  }
  int p = 0, q = 0, count = 0, ans = 0;
  for (i = 0; i < n; i++) {
    p = a[i];
    count = 0;
    q = 0;
    while (p > 1) {
      p = p / 2;
      count++;
    }
    if (a[i] == power[count]) {
      while (i + 1 < n && a[i + 1] == a[i]) {
        q++;
        i++;
      }
    }
    if (q > 0) {
      continue;
    }
    int r = 0;
    for (j = count + 1; j < 32; j++) {
      int s = binarySearch(a, 0, n, power[j] - a[i]);
      if (s != -1 && s != i) {
        r = 1;
        break;
      }
    }
    if (r == 0) {
      ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}
