#include <bits/stdc++.h>
using namespace std;
int n, tmp;
int req(vector<int> tt, int bt) {
  if (tt.empty() || bt < 0) return 0;
  vector<int> tr, fl;
  for (auto it : tt) {
    if ((it >> bt) & 1)
      tr.emplace_back(it);
    else
      fl.emplace_back(it);
  }
  if (tr.empty()) return req(fl, bt - 1);
  if (fl.empty()) return req(tr, bt - 1);
  return min(req(fl, bt - 1), req(tr, bt - 1)) + (1 << bt);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  vector<int> a;
  cin >> n;
  while (n--) {
    cin >> tmp;
    a.emplace_back(tmp);
  }
  int ans = req(a, 30);
  cout << ans << endl;
  return 0;
}
