#include <bits/stdc++.h>
using namespace std;
vector<long long> a;
vector<vector<long long>> v;
long long fun(long long low, long long high, long long bit) {
  if (bit < 1) return 0;
  long long val = 1LL << (bit - 1);
  if (a[low] & val) return fun(low, high, bit - 1);
  if (!(a[high] & val)) return fun(low, high, bit - 1);
  long long idx =
      lower_bound(v[bit - 1].begin() + low, v[bit - 1].begin() + high, 1) -
      v[bit - 1].begin();
  return val + min(fun(low, idx - 1, bit - 1), fun(idx, high, bit - 1));
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  a = vector<long long>(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  long long bit = 30;
  v = vector<vector<long long>>(31, vector<long long>(n));
  for (long long i = 0; i < n; i++) {
    for (long long j = 1; j < 31; j++) {
      v[j - 1][i] = a[i] & (1LL << (j - 1));
    }
  }
  cout << fun(0, n - 1, 30) << endl;
  return 0;
}
