#include <bits/stdc++.h>
using namespace std;
map<long long int, long long int> mp;
map<long long int, long long int> cnt;
long long int arr[120005];
long long int vis[120005];
int main() {
  ios_base::sync_with_stdio(0);
  long long int i, j, k, m, n, c = 0, x, y;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> arr[i];
    mp[arr[i]] = 1;
    cnt[arr[i]]++;
  }
  fill(vis, vis + n + 1, 0);
  for (i = 1; i <= n; i++) {
    for (j = 0; j <= 30; j++) {
      if ((1 << j) < arr[i])
        continue;
      else if ((1 << j) == arr[i]) {
        if (cnt[arr[i]] > 1) {
          vis[i] = 1;
        }
      } else if (mp[(1 << j) - arr[i]] == 1) {
        if ((1 << j) - arr[i] != arr[i])
          vis[i] = 1;
        else if (cnt[arr[i]] > 1) {
          vis[i] = 1;
        }
      }
    }
  }
  for (i = 1; i <= n; i++) {
    if (vis[i] == 0) c++;
  }
  cout << c;
  return 0;
}
