#include <bits/stdc++.h>
std::map<long long, long long> m;
long long a[230010], mi[230010];
int n;
int main() {
  int flag, sum = 0;
  mi[0] = 1;
  for (int i = 1; i < 31; i++) mi[i] = mi[i - 1] * 2;
  scanf("%d", &n);
  m.clear();
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
    m[a[i]]++;
  }
  for (int i = 0; i < n; i++) {
    flag = 0;
    for (int j = 0; j < 31; j++) {
      if (a[i] > mi[j]) continue;
      if (m[mi[j] - a[i]]) {
        if (mi[j] == 2 * a[i]) {
          if (m[mi[j] - a[i]] > 1) {
            flag = 1;
            break;
          }
        } else {
          flag = 1;
          break;
        }
      }
    }
    if (flag) sum++;
  }
  printf("%d", n - sum);
}
