#include <bits/stdc++.h>
using namespace std;
long long calc(vector<long long>& a, int n) {
  if (a.size() == 0 || n < 0) return 0;
  vector<long long> l, r;
  for (int i = 0; i < a.size(); ++i) {
    if ((1 << n) & a[i])
      l.push_back(a[i]);
    else
      r.push_back(a[i]);
  }
  if (l.empty()) return calc(r, n - 1);
  if (r.empty()) return calc(l, n - 1);
  return min(calc(l, n - 1), calc(r, n - 1)) + (1 << n);
}
signed main() {
  std::ios_base::sync_with_stdio(0), cin.tie(0);
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  cout << calc(a, 30);
  return 0;
}
