#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 7;
vector<long long> vec;
long long solve(vector<long long>& a, long long i) {
  if (i == -1) return 0;
  vector<long long> a1, a0;
  for (long long x : a)
    if (x & (1 << i))
      a1.push_back(x);
    else
      a0.push_back(x);
  if (a0.empty() || a1.empty()) return solve(a, i - 1);
  return min(solve(a1, i - 1), solve(a0, i - 1)) + (1 << i);
}
int32_t main() {
  long long n;
  cin >> n;
  for (long long i = 0, x; i < n; i++) cin >> x, vec.push_back(x);
  cout << solve(vec, 30) << endl;
}
