#include <bits/stdc++.h>
using namespace std;
long long sl[65], data[1000005];
map<long long, int> mlli;
int main() {
  sl[1] = 2;
  for (int i = 2; i <= 60; i++) {
    sl[i] = sl[i - 1] * 2;
  }
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &data[i]);
    mlli[data[i]]++;
  }
  int ans = 0;
  sort(data + 1, data + 1 + n);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 60; j++) {
      if (sl[j] - data[i] > data[n]) {
        ans++;
        break;
      }
      if (mlli[sl[j] - data[i]] > 1 ||
          (mlli[sl[j] - data[i]] == 1 && data[i] != sl[j] - data[i])) {
        break;
      }
      if (j == 60) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
