#include <bits/stdc++.h>
using namespace std;
int64_t find_pivot(int64_t left, int64_t right, vector<int64_t>& a,
                   int64_t mask) {
  auto pivot_it = std::lower_bound(a.begin() + left, a.begin() + right, mask,
                                   [&mask](int64_t lhs, int64_t rhs) {
                                     return (lhs & mask) < (rhs & mask);
                                   });
  return pivot_it - a.begin();
}
int64_t f(int64_t left, int64_t right, vector<int64_t>& a, int64_t mask) {
  int64_t res = 0;
  if ((a[left] & mask) != (a[right - 1] & mask)) {
    res = mask;
    int64_t med = find_pivot(left, right, a, mask);
    mask >>= 1;
    int64_t res_left = f(left, med, a, mask);
    int64_t res_right = f(med, right, a, mask);
    return res | std::min(res_left, res_right);
  }
  if (mask == 0) {
    return 0;
  }
  mask >>= 1;
  return f(left, right, a, mask);
}
int main() {
  int64_t n;
  cin >> n;
  vector<int64_t> a(n);
  for (auto& elem : a) {
    cin >> elem;
  }
  std::sort(a.begin(), a.end());
  int64_t mask = 1 << 30;
  int64_t left = 0;
  int64_t right = a.size();
  cout << f(left, right, a, mask) << endl;
  return 0;
}
