#include <bits/stdc++.h>
inline long long read() {
  long long x = 0;
  char ch = getchar(), w = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * w;
}
void write(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
inline void writeln(long long x) {
  write(x);
  puts("");
}
using namespace std;
const int N = 1e5 + 666;
long long a[N], n;
long long cal(int x, int l, int r) {
  if (x == -1) return 0;
  int p = l;
  while (!(a[p] >> x & 1) && p <= r) ++p;
  if (p > r || p == l) return cal(x - 1, l, r);
  return min(cal(x - 1, l, p - 1), cal(x - 1, p, r)) + (1ll << x);
}
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) a[i] = read();
  sort(a + 1, a + 1 + n);
  writeln(cal(30, 1, n));
  return 0;
}
