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