#include <bits/stdc++.h>
using namespace std;
const int maxn = 120010;
int vis[maxn];
long long power2[32];
int a[maxn];
int b[maxn];
int main() {
  power2[0] = 1;
  for (int i = 1; i < 32; i++) power2[i] = power2[i - 1] * 2;
  int n;
  while (~scanf("%d", &n)) {
    memset(vis, 0, sizeof(vis));
    for (int i = 0; i < n; i++) {
      scanf("%d", &a[i]);
      b[i] = a[i];
    }
    sort(b, b + n);
    sort(a, a + n);
    int f = unique(b, b + n) - b;
    for (int i = 0; i < n; i++) {
      int x = lower_bound(b, b + f, a[i]) - b;
      ++vis[x];
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
      int x = lower_bound(b, b + f, a[i]) - b;
      int y;
      int flag = 0;
      for (int j = 0; j < 32; j++) {
        y = lower_bound(b, b + f, power2[j] - a[i]) - b;
        if (b[x] + b[y] == power2[j]) {
          if (x != y || (x == y && vis[x] > 1)) {
            flag = 1;
            break;
          }
        }
      }
      if (!flag) {
        ++ans;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
