#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int dfs(vector<int>& v, int pos) {
  vector<int> v0, v1;
  if (pos < 0) return 0;
  for (auto i : v) {
    if ((i >> pos) & 1)
      v1.push_back(i);
    else
      v0.push_back(i);
  }
  if (v0.size() == 0) return dfs(v1, pos - 1);
  if (v1.size() == 0) return dfs(v0, pos - 1);
  return min(dfs(v1, pos - 1), dfs(v0, pos - 1)) + (1 << pos);
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    v.push_back(x);
  }
  cout << dfs(v, 30) << endl;
}
