#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
#define ll long long
#define inf 20021225
#define mxn 200010
using namespace std;
ll a[mxn];int n;
map<ll,int> mp;
int main()
{
	int ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	sort(a+1,a+n+1);
	for(int i=n;i;i--)
	{
		ll j;
		for(j=(1ll<<33);j>a[i];j>>=1ll)
			if(mp[j-a[i]])	break;
		if(j>a[i])	ans++,mp[j-a[i]]--;
		else mp[a[i]]++;
	}
	printf("%d\n",ans);
	return 0;
}