#include <bits/stdc++.h>
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define _CRT_SECURE_NO_WARNINGS
#define endl '\n'
#define time clock_t tStart = clock();
#define show printf("Time taken: %.6fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
#define loop(a,b) for(int i=a;i<=b;++i)
#define count_1(n) __builtin_popcountll(n)
#define pb push_back
#define f first
#define s second
#define MOD 1000000007
#define itoc(c) ((char)(((int)'0')+c))
#define V vector<int>
#define Vl vector<ll>
#define pll pair<ll,ll>
#define Vp vector<pair<int,int>>
#define all(v) v.begin(),v.end()
#define mid(s,e) (s+(e-s)/2)
#define tcase() ll t,n; cin>>t;n=t; while(t--)
#define eb emplace_back
#define ull unsigned long long
#define minimize INT_MAX
#define maximize INT_MIN
#define dsort(a) sort(a.begin(), a.end(), greater<int>())
#define fr(i,n) for(ll i=0; i<n; i++)
#define fr1(i,n) for(ll i=1; i<=n; i++)
#define vp(n) vector<pair<int,int>>v(n);
#define si set <int>
void fast(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//cout.setf(ios::fixed);
//cout.precision(20);
#ifndef _offline
// freopen("mex.in", "r", stdin);
//freopen("output.txt", "w", stdout);
#endif
}
void HaXn() {
int n; cin >>n;
vector<ll> v(n);
map <ll, ll>mp;
fr(i,n) cin >> v[i], mp[v[i]]++;
vector<ll>pow(34);
ll p=1;
pow[0] =p;
for (int i =1; i<=33; i++){
pow[i] = p*=2;
}
ll count =0;
for (int i =0; i<n; i++){
bool ok = false;
mp[v[i]]--;
for (int j =0; j<=33; j++){
ll val = pow[j] - v[i];
if (mp[val]){
ok = true;
break;
}
}
if (!ok) count ++;
mp[v[i]]++;
}
cout << count << endl;
}
int main() {
fast();
HaXn();
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPHNldD4KI2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPGNtYXRoPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwojZGVmaW5lIGxsICAgICAgICAgICAgICAgICAgICAgbG9uZyBsb25nCiNkZWZpbmUgX0NSVF9TRUNVUkVfTk9fV0FSTklOR1MKI2RlZmluZSBlbmRsICAgICAgICAgICAgICAgICAgICdcbicKI2RlZmluZSB0aW1lIGNsb2NrX3QgdFN0YXJ0ID0gY2xvY2soKTsKI2RlZmluZSBzaG93IHByaW50ZigiVGltZSB0YWtlbjogJS42ZnNcbiIsIChkb3VibGUpKGNsb2NrKCkgLSB0U3RhcnQpL0NMT0NLU19QRVJfU0VDKTsKI2RlZmluZSBsb29wKGEsYikgICAgICAgICAgICAgZm9yKGludCBpPWE7aTw9YjsrK2kpCiNkZWZpbmUgY291bnRfMShuKSAgICAgICAgICAgIF9fYnVpbHRpbl9wb3Bjb3VudGxsKG4pCiNkZWZpbmUgcGIgICAgICAgICAgICAgICAgICAgIHB1c2hfYmFjawojZGVmaW5lIGYgICAgICAgICAgICAgICAgICAgICBmaXJzdAojZGVmaW5lIHMgICAgICAgICAgICAgICAgICAgICBzZWNvbmQKI2RlZmluZSBNT0QgICAgICAgICAgICAgICAgICAgMTAwMDAwMDAwNwojZGVmaW5lIGl0b2MoYykgICAgICAgICAgICAgICAoKGNoYXIpKCgoaW50KScwJykrYykpCiNkZWZpbmUgViAgICAgICAgICAgICAgICAgICAgIHZlY3RvcjxpbnQ+CiNkZWZpbmUgVmwgICAgICAgICAgICAgICAgICAgICAgdmVjdG9yPGxsPgojZGVmaW5lIHBsbCAgICAgICAgICAgICAgICAgICBwYWlyPGxsLGxsPgojZGVmaW5lIFZwICAgICAgICAgICAgICAgICAgICB2ZWN0b3I8cGFpcjxpbnQsaW50Pj4KI2RlZmluZSBhbGwodikgICAgICAgICAgICAgICAgdi5iZWdpbigpLHYuZW5kKCkKI2RlZmluZSBtaWQocyxlKSAgICAgICAgICAgICAgKHMrKGUtcykvMikKI2RlZmluZSB0Y2FzZSgpICAgICAgICAgICAgICAgbGwgdCxuOyBjaW4+PnQ7bj10OyB3aGlsZSh0LS0pCiNkZWZpbmUgZWIgICAgICAgICAgICAgICAgICAgIGVtcGxhY2VfYmFjawojZGVmaW5lIHVsbCAgICAgICAgICAgICAgICAgICB1bnNpZ25lZCBsb25nIGxvbmcKI2RlZmluZSBtaW5pbWl6ZSAgICAgICAgICAgICAgSU5UX01BWAojZGVmaW5lIG1heGltaXplICAgICAgICAgICAgICBJTlRfTUlOCiNkZWZpbmUgZHNvcnQoYSkgICAgICAgICAgICAgIHNvcnQoYS5iZWdpbigpLCBhLmVuZCgpLCBncmVhdGVyPGludD4oKSkKI2RlZmluZSBmcihpLG4pICAgICAgICAgICAgICAgZm9yKGxsIGk9MDsgaTxuOyBpKyspCiNkZWZpbmUgZnIxKGksbikgICAgICAgICAgICAgIGZvcihsbCBpPTE7IGk8PW47IGkrKykKI2RlZmluZSB2cChuKSAgICAgICAgICAgICAgICB2ZWN0b3I8cGFpcjxpbnQsaW50Pj52KG4pOwojZGVmaW5lIHNpICAgICAgICAgICAgICAgICAgIHNldCA8aW50PgoKdm9pZCBmYXN0KCl7CiAgICBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKDApOwogICAgY2luLnRpZSgwKTsKICAgIGNvdXQudGllKDApOwogICAgLy9jb3V0LnNldGYoaW9zOjpmaXhlZCk7CiAgICAvL2NvdXQucHJlY2lzaW9uKDIwKTsKICAgICNpZm5kZWYgX29mZmxpbmUKICAgIC8vIGZyZW9wZW4oIm1leC5pbiIsICJyIiwgc3RkaW4pOwogICAgLy9mcmVvcGVuKCJvdXRwdXQudHh0IiwgInciLCBzdGRvdXQpOwogICAgI2VuZGlmCn0KCgoKCnZvaWQgSGFYbigpIHsKICBpbnQgbjsgY2luID4+bjsKICB2ZWN0b3I8bGw+IHYobik7CiAgbWFwIDxsbCwgbGw+bXA7CiAgZnIoaSxuKSBjaW4gPj4gdltpXSwgbXBbdltpXV0rKzsKICB2ZWN0b3I8bGw+cG93KDM0KTsKCiAgICBsbCBwPTE7CiAgICBwb3dbMF0gPXA7CiAgICBmb3IgKGludCBpID0xOyBpPD0zMzsgaSsrKXsKICAgICAgICBwb3dbaV0gPSBwKj0yOwogICAgfQoKICAgIGxsIGNvdW50ID0wOwoKICBmb3IgKGludCBpID0wOyBpPG47IGkrKyl7CiAgICAgIGJvb2wgb2sgPSBmYWxzZTsKICAgICAgbXBbdltpXV0tLTsKICAgICAgZm9yIChpbnQgaiA9MDsgajw9MzM7IGorKyl7CiAgICAgICAgICBsbCB2YWwgPSBwb3dbal0gLSB2W2ldOwogICAgICAgICAgaWYgKG1wW3ZhbF0pewogICAgICAgICAgICAgIG9rID0gdHJ1ZTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgfQogICAgICBpZiAoIW9rKSBjb3VudCArKzsKICAgICAgbXBbdltpXV0rKzsKICB9CiAgY291dCA8PCBjb3VudCA8PCBlbmRsOwoKfQoKCgoKCmludCBtYWluKCkgewogICAgZmFzdCgpOwogICAgSGFYbigpOwp9