#include <bits/stdc++.h>
using namespace std;
int n;
int fun(int x, vector<int> a) {
  if (x < 0) {
    return 0;
  }
  vector<int> zero, one;
  for (int i = 0; i < a.size(); i++) {
    if (((a[i] >> x) & 1) == 0) {
      zero.push_back(a[i]);
    } else {
      one.push_back(a[i]);
    }
  }
  if (zero.size() == 0) {
    return fun(x - 1, one);
  } else if (one.size() == 0) {
    return fun(x - 1, zero);
  } else {
    return (1 << x) + min(fun(x - 1, zero), fun(x - 1, one));
  }
}
int main() {
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  cout << fun(30, a);
}
