#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const long long LINF = LLONG_MAX, base = 1e9, MOD = 1e9 + 7, N = 30,
                M = 1e3 + 5, LG = 20;
const int INF = INT_MAX;
const double PI = acos(-1), EPS = 1 / double(1e6);
mt19937_64 rang(
    chrono::high_resolution_clock::now().time_since_epoch().count());
struct trie {
  trie* next[2];
  int cnt = 0;
};
trie* head;
void add(int x) {
  trie* cur = head;
  for (int i = N; i >= 0; --i) {
    bool bit = (x >> i) & 1;
    if (cur->next[bit] == NULL) {
      cur->next[bit] = new trie();
    }
    cur = cur->next[bit];
    ++cur->cnt;
  }
}
int solve(trie* cur, int bit) {
  if (cur == NULL) {
    return -(1 << 30);
  }
  if (bit < 0) {
    return 0;
  }
  int shift = (1 << bit);
  int ze = solve(cur->next[0], bit - 1), on = solve(cur->next[1], bit - 1);
  return min(max(ze + shift, on), max(ze, on + shift));
}
void test() {
  int n;
  cin >> n;
  head = new trie();
  for (int i = 0, a; i < n; ++i) {
    cin >> a;
    add(a);
  }
  cout << solve(head, N) << "\n";
}
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(15);
  test();
  return 0;
}
