#include <bits/stdc++.h>
using namespace std;
void QuickStart() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}
const int inf = 1e9;
vector<int> v;
int rec(int l, int r, int bit) {
  if (bit == 0) {
    return (v[l] & 1) != (v[r] & 1);
  }
  int m = inf;
  for (int i = l; i <= r; i++) {
    if (v[i] & (1 << bit)) {
      m = i;
      break;
    }
  }
  if (m == l || m == inf) {
    return rec(l, r, bit - 1);
  }
  int ansl = rec(l, m - 1, bit - 1), ansr = rec(m, r, bit - 1);
  return (1 << bit) | (min(ansl, ansr));
}
void solve() {
  int n;
  cin >> n;
  v.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  cout << rec(0, n - 1, 30);
}
int main() {
  QuickStart();
  solve();
}
