#include <bits/stdc++.h>
using namespace std;
using namespace std;
const int INF = int(1e9), mod = 1000000007, N = 120005;
const long long BIG = int(1e17);
int n, a[N], ans;
vector<int> vec;
map<int, int> m, w;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    m[a[i]]++;
  }
  int num = 1;
  for (int i = 1; i <= 30; i++) {
    vec.push_back(num * 2);
    num *= 2;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 30; j++) {
      int x = vec[j] - a[i];
      if (x <= 0 || (x == a[i] && m[a[i]] == 1)) continue;
      if (m[x]) {
        w[x] = 1;
        w[a[i]] = 1;
        break;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (!w[a[i]]) {
      ans++;
    }
  }
  cout << ans;
}
