#include <bits/stdc++.h>   using namespace std;   const int Max = 2e5 + 10;   const int LOG = 30;   const int INF = 1e9 + 10;   struct Trie {     int l[Max * LOG], r[Max * LOG];     int cnt[Max * LOG];     int sz = 1;     int index[Max * LOG];     int dp[Max * LOG][2];     void insert(int x, int ind) {       int p = 1;       for (int lg = LOG; lg--;) {         cnt[p]++;         if (x & (1 << lg))           if (r[p])             p = r[p];           else             p = r[p] = ++sz;         else if (l[p])           p = l[p];         else           p = l[p] = ++sz;       }       cnt[p]++;       index[p] = ind;     }     int mnxor(int x) {       int p = 1;       bool firstdiff = false;       for (int lg = LOG; lg--;) {         if (!firstdiff) {           if (x & (1 << lg))             if (cnt[r[p]] > 1)               p = r[p];             else {               p = l[p];               firstdiff = true;             }           else if (cnt[l[p]] > 1)             p = l[p];           else {             p = r[p];             firstdiff = true;           }         } else {           if (x & (1 << lg))             if (r[p])               p = r[p];             else               p = l[p];           else if (l[p])             p = l[p];           else             p = r[p];         }       }       return index[p];     }     void DP(int v) {       if (r[v]) DP(r[v]);       if (l[v]) DP(l[v]);       dp[v][0] = cnt[v] - 1;       dp[v][1] = min(dp[l[v]][0] + dp[r[v]][1], dp[r[v]][0] + dp[l[v]][1]);     }   };   Trie t;   int A[Max];   vector<int> N[Max];   bool seen[Max];   int DFS(int v) {     seen[v] = true;     int res = 1;     for (int u : N[v])       if (!seen[u]) res += DFS(u);     return res;   }   void solve() {     int n;     cin >> n;     for (int i = 0; i < n; i++) {       int a;       cin >> a;       A[i] = a;       t.insert(a, i);     }     for (int i = 0; i < n; i++) {       int from = i;       int to = t.mnxor(A[i]);       N[from].push_back(to);       N[to].push_back(from);     }     int molcnt = 0;     int mxmol = 0;     for (int i = 0; i < n; i++)       if (!seen[i]) {         molcnt++;         mxmol = max(mxmol, DFS(i));       }     t.DP(1);     cout << t.dp[1][1];   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     solve();   }   