#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
using namespace std;
clock_t start_time, end_time;
void open() {
  ((void)0);
  ((void)0);
  ((void)0);
  ((void)0);
}
void close() {
  ((void)0);
  ((void)0);
}
const int MAX = 1e5 + 1;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long LL_INF = 0x3f3f3f3f3f3f3f3fLL;
const double PI = acos(-1);
const long double ERR = 1e-10;
const int move_r[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int move_c[] = {0, -1, 0, 1, -1, 1, -1, 1};
int n, a[MAX];
int solve(int lo, int hi, int p) {
  if (lo == hi || p < 0) return 0;
  int bit = 1 << p;
  if ((a[lo] ^ a[hi]) & bit) {
    int m = hi;
    while (a[m] & bit) m--;
    return (1 << p) | min(solve(lo, m, p - 1), solve(m + 1, hi, p - 1));
  } else
    return solve(lo, hi, p - 1);
}
int main(int argc, char *argv[]) {
  open();
  scanf("%d", &n);
  int _and = (1 << 30) - 1, _or = 0;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", a + i);
    _and &= a[i];
    _or |= a[i];
  }
  int all_same = _and | (_or ^ ((1 << 30) - 1));
  int diff = all_same ^ ((1 << 30) - 1);
  for (int i = 1; i <= n; ++i) a[i] &= diff;
  sort(a + 1, a + n + 1);
  printf("%d\n", solve(1, n, 29));
  close();
  return 0;
}
