#include <bits/stdc++.h>   using namespace std;   map<int, int> m;   bool fd(int x, int y) {     if (x == y) return m[y] >= 2;     return m.find(y) != m.end();   }   int main() {     int n;     cin >> n;     for (int i = 0; i < (n); i++) {       int x;       cin >> x;       m[x]++;     }     int cnt = 0;     for (auto& xp : m) {       int x = xp.first;       for (int s = 1; s <= 30; s++) {         if ((1 << s) <= x) continue;         if (fd(x, (1 << s) - x)) goto cont;       }       cnt += xp.second;     cont:;     }     cout << cnt << endl;     return 0;   }   