#include <bits/stdc++.h>
using namespace std;
template <class T>
T power(T N, T P) {
  return (P == 0) ? 1 : N * power(N, P - 1);
}
int n;
int solve(vector<int>& v, int bit) {
  if (bit < 0) return 0;
  vector<int> l, r;
  for (auto it : v) {
    if (it & (1 << bit))
      l.push_back(it);
    else
      r.push_back(it);
  }
  if (l.empty())
    return solve(r, bit - 1);
  else if (r.empty())
    return solve(l, bit - 1);
  else
    return (1 << bit) + min(solve(l, bit - 1), solve(r, bit - 1));
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  vector<int> v;
  v.resize(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  cout << solve(v, 30);
  return 0;
}
