#include <bits/stdc++.h>
using namespace std;
long long check(long long n, long long pos) {
  if (n & (1LL << pos)) return 1;
  return 0;
}
long long Set(long long n, long long pos) { return n = n | (1LL << pos); }
long long tree[3000006][2];
long long node;
void ins(long long num) {
  long long curr = 0;
  for (long long i = 30; i >= 0; i--) {
    long long x = check(num, i);
    if (tree[curr][x] == -1) {
      tree[curr][x] = ++node;
    }
    curr = tree[curr][x];
  }
}
long long srch(long long curr, long long bit) {
  if (curr < 0) return 0;
  long long val = 1LL << bit;
  if (tree[curr][0] != -1 && tree[curr][1] != -1)
    return min(srch(tree[curr][0], bit - 1), srch(tree[curr][1], bit - 1)) +
           val;
  if (tree[curr][0] != -1) return srch(tree[curr][0], bit - 1);
  if (tree[curr][1] != -1) return srch(tree[curr][1], bit - 1);
  return 0;
}
int main() {
  long long i, j, k, l, m, n, o, r, q;
  long long testcase;
  long long input, flag, tag, ans;
  while (cin >> n) {
    memset(tree, -1, sizeof tree);
    node = 0;
    for (i = 1; i <= n; i++) {
      scanf("%lld", &input);
      ins(input);
    }
    ans = srch(0, 30);
    cout << ans << endl;
  }
}
