#include <bits/stdc++.h>
using namespace std;
int n, a[120005], ans;
map<int, int> p;
vector<int> tw;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    p[a[i]]++;
  }
  tw.push_back(1);
  for (int i = 1; tw.push_back(tw[i - 1] * 2), i <= 31; i++)
    ;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= 30; j++) {
      if (tw[j] <= a[i]) continue;
      int tmp = p[tw[j] - a[i]];
      if (tmp > (tw[j] - a[i] == a[i])) goto yalla;
    }
    ans++;
  yalla:
    n = n;
  }
  cout << ans;
  return 0;
}
