#include <bits/stdc++.h>
using namespace std;
bool bs(int *arr, int i, int n, long long a) {
  int l = 0, u = n - 1, m;
  while (l <= u) {
    m = l + (u - l) / 2;
    if (arr[m] == a) {
      if (m != i)
        return true;
      else {
        if (m > 0)
          if (arr[m - 1] == a) return true;
        if (m < u)
          if (arr[m + 1] == a) return true;
        break;
      }
    } else if (arr[m] < a)
      l = m + 1;
    else
      u = m - 1;
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  int arr[n];
  for (auto &i : arr) cin >> i;
  sort(arr, arr + n);
  long long a, b, u = 2 * arr[n - 1];
  int ans = 0;
  for (int i = 0; i < n; i++) {
    b = log2(arr[i]);
    a = pow(2, b);
    bool check = false;
    while (a <= u) {
      check = bs(arr, i, n, a - arr[i]);
      if (check) break;
      a *= 2;
    }
    if (!check) ans++;
  }
  cout << ans;
  return 0;
}
