#include <bits/stdc++.h>
using namespace std;
vector<int> a;
int solve(vector<int> v, int bit) {
  if (bit == -1) {
    return 0;
  }
  vector<int> a, b;
  for (auto i : v) {
    if ((1LL << bit) & i)
      a.push_back(i);
    else
      b.push_back(i);
  }
  if ((int)a.size() == 0)
    return solve(b, bit - 1);
  else if ((int)b.size() == 0)
    return solve(a, bit - 1);
  else
    return (1LL << bit) + min(solve(a, bit - 1), solve(b, bit - 1));
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a.push_back(x);
  }
  cout << solve(a, 32);
  return 0;
}
