#include <bits/stdc++.h>
using namespace std;
int solve(vector<int> x, int bit) {
  if (bit < 0) {
    return 0;
  }
  int z = x.size();
  vector<int> on;
  vector<int> off;
  for (int i = 0; i < z; i++) {
    if (((x[i] >> bit) & 1) == 0) {
      off.push_back(x[i]);
    } else {
      on.push_back(x[i]);
    }
  }
  if (on.size() == 0) {
    return solve(off, bit - 1);
  }
  if (off.size() == 0) {
    return solve(on, bit - 1);
  }
  return min(solve(off, bit - 1), solve(on, bit - 1)) + (1 << bit);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a.push_back(x);
  }
  cout << solve(a, 30) << "\n";
  return 0;
}
