#include <bits/stdc++.h>   using namespace std;   const long long int MOD = 1e9 + 7;   const long long int INF = 2e15;   const long long int MAXN = 2e5 + 5;   long long int fastexpo(long long int b, long long int exp) {     if (exp == 0) return 1;     if (exp == 1) return b;     long long int ans = (fastexpo(b, exp / 2) % MOD);     ans *= ans;     ans %= MOD;     if (exp % 2 == 1) {       ans *= b;     }     ans %= MOD;     return ans;   }   long long int n;   vector<long long int> a;   long long int dp[MAXN][4];   long long int solve(long long int idx, vector<long long int> nice,                       long long int which) {     if (idx < 0) {       return 0;     }     if (nice.size() == 1) {       return 0;     }     vector<long long int> o, z;     for (long long int i = 0; i < nice.size(); i++) {       if ((1LL << idx) & nice[i]) {         o.push_back(nice[i]);       } else {         z.push_back(nice[i]);       }     }     long long int lo = o.size();     long long int lz = z.size();     if (min(lo, lz) <= 1) {       if (max(lo, lz) <= 1) {         return 0;       } else {         if (lo <= 1) {           return solve(idx - 1, z, 0);         } else {           return solve(idx - 1, o, 1);         }       }     }     return dp[idx][which] =                min(solve(idx - 1, o, 1) + max((lz - 1), (long long int)0),                    solve(idx - 1, z, 0) + max((lo - 1), (long long int)0));   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> n;     memset(dp, -1, sizeof(dp));     ;     long long int mx = 0;     for (long long int i = 0; i < n; i++) {       long long int x;       cin >> x;       a.push_back(x);       mx = max(mx, (long long int)log2(x));     }     cout << solve(mx, a, 2) <<   n ;     return 0;   }   