#include <bits/stdc++.h>
using namespace std;
int rec(vector<int> &c, int bit) {
  if (bit < 0) return 0;
  int bit2 = pow(2, bit);
  vector<int> l, r;
  for (auto &i : c) {
    if (i & bit2)
      r.push_back(i);
    else
      l.push_back(i);
  }
  if (l.size() == 0)
    return rec(r, bit - 1);
  else if (r.size() == 0)
    return rec(l, bit - 1);
  else if (l.size() && r.size())
    return min(rec(r, bit - 1), rec(l, bit - 1)) + bit2;
}
int main(void) {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  cout << rec(a, 30);
  return 0;
}
