#include <bits/stdc++.h>
#pragma optimize("O3")
using namespace std;
const long long MOD = 998244353;
const long long INF = 1e9;
const int base = 2e5 + 1;
const long long MAX = 5 * 1e7 + 1;
const double EPS = 1e-9;
const double PI = acos(-1.);
const int MAXN = 200000 + 47;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int res = 0;
int f(vector<int> v, int i, int mask = 0) {
  res = max(res, mask);
  if (v.empty() || i < 0) return 0;
  vector<int> a, b;
  for (auto x : v) {
    if ((x & (1 << i)) != 0) {
      a.push_back(x);
    } else
      b.push_back(x);
  }
  if ((int)a.size() * (int)b.size()) {
    return min(f(a, i - 1), f(b, i - 1)) + (1 << i);
  } else {
    return f(v, i - 1);
  }
}
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (long long i = (0); i < (n); ++i) cin >> v[i];
  cout << f(v, 30);
  return 0;
}
