#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    int ans = 0;
    multiset<int> s(a.begin(), a.end());
    while(!s.empty()) {
        auto it = prev(s.end());
        int a = *it;
        s.erase(it);
        int b = (1LL << (32 - __builtin_clz(a))) - a;
        it = s.find(b);
        if(it != s.end()) {
            ans++;
            s.erase(it);
        }
    }
    cout << ans << endl;
    return 0;
}

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  int ans = 1e9;
  rep(i, n) {
    int c = 0;
    while (a[i] % 2 == 0) {
      a[i] /= 2;
      c++;
    }
    ans = min(ans, c);
  }
  cout << ans << endl;
  return 0;
}