#include <bits/stdc++.h>
using namespace std;
int n;
long long solve(const vector<long long> &x, int pos) {
  if (pos == -1) return 0;
  vector<long long> zero;
  vector<long long> one;
  for (long long y : x)
    if ((y >> pos) & 1)
      one.emplace_back(y);
    else
      zero.emplace_back(y);
  if (one.empty()) return solve(zero, pos - 1);
  if (zero.empty()) return solve(one, pos - 1);
  return (1LL << pos) + min(solve(zero, pos - 1), solve(one, pos - 1));
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  vector<long long> a(n);
  for (long long &i : a) cin >> i;
  cout << solve(a, 29);
  return 0;
}
