#include using namespace std; int solve(int d, vector& v) { if (v.size() <= 1) return 0; vector w[2]; for (int x : v) { w[(x >> d) & 1].push_back(x); } if (w[0].empty()) return solve(d - 1, w[1]); if (w[1].empty()) return solve(d - 1, w[0]); int res = (1 << d); res += min(solve(d - 1, w[0]), solve(d - 1, w[1])); return res; } int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector a(n); for (int i = 0; i < n; i++) cin >> a[i]; sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); cout << solve(29, a) << endl; return 0; }