#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const long long MOD = 1e9 + 7;
long double EPS = 1e-12;
const long long INF32 = 0x3F3F3F3F;
const long long INF = 0x3F3F3F3F3F3F3F3F;
const long long crng = rng();
const long long N = 1e5 + 5;
long long n;
long long DFS(long long lv, long long l, long long r, vector<long long> &a) {
  if (l == r || lv < 0) return 0;
  long long d = l - 1;
  for (long long i = l; i <= r; i++) {
    if ((a[i] >> lv) & 1LL) break;
    d = i;
  }
  if (d == l - 1 || d == r) return DFS(lv - 1, l, r, a);
  long long x = DFS(lv - 1, l, d, a);
  long long y = DFS(lv - 1, d + 1, r, a);
  return min(x, y) + (1LL << lv);
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ifstream fin("input.txt");
  ofstream fout("output.txt");
  {
    cin >> n;
    vector<long long> a(n);
    for (long long i = 0; i <= n - 1; i++) cin >> a[i];
    sort((a).begin(), (a).end());
    cout << DFS(30, 0, n - 1, a) << '\n';
  }
}
