#include <bits/stdc++.h>
using namespace std;
int n;
int a[120010];
long long p[40];
map<int, int> mp;
int main() {
  scanf("%d", &n);
  for (int i = 0; i <= 32; i++) {
    if (i == 0) {
      p[i] = 1;
    } else {
      p[i] = p[i - 1] * 2;
    }
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (!mp.count(a[i])) {
      mp[a[i]] = 1;
    } else {
      mp[a[i]]++;
    }
  }
  int j;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (j = 0; j <= 32; j++) {
      int k = p[j] - a[i];
      if (k <= 0) {
        continue;
      }
      if ((k == a[i] && mp[k] >= 2) || (k != a[i] && mp[k] >= 1)) {
        break;
      }
    }
    if (j == 33) {
      ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}
