#include <bits/stdc++.h>
using namespace std;
long long n;
long long ans(vector<long long> &a, long long bit) {
  if (bit < 0) return 0;
  vector<long long> setbit, unsetbit;
  for (long long i : a) {
    if (((1 << bit) & i) > 0) {
      setbit.push_back(i);
    } else
      unsetbit.push_back(i);
  }
  if (setbit.size() == 0) return ans(unsetbit, bit - 1);
  if (unsetbit.size() == 0) return ans(setbit, bit - 1);
  return ((1 << bit) + min(ans(setbit, bit - 1), ans(unsetbit, bit - 1)));
}
signed main() {
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  cout << ans(a, 30);
}
