#include #include using namespace std; int n, a[100005]; int func(int k, int l, int r){ if(k == -1) return 0; int m = r; for(int i = l; i < r; ++i){ if(a[i] >> k & 1) { m = i; break; } } int res = 1001001001; if(l < m) res = min(res, func(k - 1, l, m)); if(m < r) res = min(res, func(k - 1, m, r)); if(l < m && m < r) res += 1 << k; return res; } int main(){ cin >> n; for(int i = 0; i < n; ++i) cin >> a[i]; sort(a, a + n); cout << func(30, 0, n) << endl; return 0; }