#include <bits/stdc++.h>
using namespace std;
long long get(vector<long long> v, long long lvl) {
  if (v.size() == 1) {
    return {0};
  }
  vector<long long> a, b;
  for (auto i : v) {
    if ((i >> lvl) & 1) {
      a.emplace_back(i);
    } else {
      b.emplace_back(i);
    }
  }
  if (a.empty()) {
    return get(b, lvl - 1);
  } else if (b.empty()) {
    return get(a, lvl - 1);
  }
  return min(get(a, lvl - 1), get(b, lvl - 1)) + (1LL << lvl);
}
signed main() {
  long long n;
  cin >> n;
  long long ans = 0;
  vector<long long> v(n);
  for (long long i = 0; i < n; ++i) {
    long long x;
    cin >> x;
    v[i] = x;
  }
  sort((v).begin(), (v).end());
  v.erase(unique((v).begin(), (v).end()), v.end());
  cout << get(v, 29);
}
