#include <bits/stdc++.h>
using namespace std;
int n, ans;
vector<int> a;
int sol(vector<int> v, int r) {
  if (r < 0) return 0;
  vector<int> t[2];
  for (int i = 0; i < v.size(); i++) t[v[i] >> r & 1].push_back(v[i]);
  if (!t[0].size() || !t[1].size())
    return sol(t[!t[0].size()], r - 1);
  else
    return min(sol(t[1], r - 1), sol(t[0], r - 1)) + (1 << r);
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int t, i = 1; i <= n; i++) cin >> t, a.push_back(t);
  ans = sol(a, 30);
  cout << ans;
  return 0;
}
