#include <bits/stdc++.h>
using namespace std;
const int N = 100007;
int n, a[N];
int dfs(int i, vector<int> &v) {
  vector<int> v0, v1;
  if (i < 0) return 0;
  for (auto &j : v) {
    if ((j >> i) & 1)
      v1.push_back(j);
    else
      v0.push_back(j);
  }
  if (v0.size() == 0) return dfs(i - 1, v1);
  if (v1.size() == 0) return dfs(i - 1, v0);
  return min(dfs(i - 1, v0), dfs(i - 1, v1)) + (1 << i);
}
vector<int> v;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), v.push_back(a[i]);
  cout << dfs(30, v);
}
