#include <bits/stdc++.h>   using namespace std;   int n;   int bin[31];   int cnt;   int ch[6000010][2];   void insert(int x) {     for (int i = 30; i >= 0; --i) {       bin[i] = x & 1;       x >>= 1;     }     int now = 0;     for (int i = 0; i <= 30; ++i) {       if (!ch[now][bin[i]]) {         ch[now][bin[i]] = ++cnt;       }       now = ch[now][bin[i]];     }   }   int getans(int l, int r, int k) {     if (k == 32) return 0;     int firmin = 1 << 30;     if (ch[l][0] && ch[r][0])       firmin = min(firmin, getans(ch[l][0], ch[r][0], k + 1));     if (ch[l][1] && ch[r][1])       firmin = min(firmin, getans(ch[l][1], ch[r][1], k + 1));     if (firmin != 1 << 30) return firmin;     int secmin = 1 << 30;     if (ch[l][1] && ch[r][0])       secmin = min(secmin, getans(ch[l][1], ch[r][0], k + 1)) + (1 << (31 - k));     if (ch[l][0] && ch[r][1])       secmin = min(secmin, getans(ch[l][0], ch[r][1], k + 1)) + (1 << (31 - k));     return secmin;   }   long long ans;   void dfs(int x, int k) {     if (ch[x][0] && ch[x][1]) {       ans += 1ll * (getans(ch[x][0], ch[x][1], k + 1) + (1 << (31 - k)));     }     if (ch[x][0]) dfs(ch[x][0], k + 1);     if (ch[x][1]) dfs(ch[x][1], k + 1);   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) {       int x;       scanf( %d , &x);       insert(x);     }     dfs(0, 1);     printf( %lld n , ans);   }   