#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f, maxn = 4000007;
const long long MOD = 1004535809;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long P = 19260817;
char nc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    x = ((x << 3) + (x << 1) + ch - '0') % MOD, ch = getchar();
  return x * f;
}
void write(int x) {
  if (!x) putchar('0');
  if (x < 0) x = -x, putchar('-');
  static int sta[20];
  register int tot = 0;
  while (x) sta[tot++] = x % 10, x /= 10;
  while (tot) putchar(sta[--tot] + 48);
}
int a[maxn];
int n;
int q1[maxn], q2[maxn];
int len1, len2;
vector<int> v;
int dfs(int dep, vector<int> &c) {
  if (c.size() == 0 || dep < 0) return 0;
  vector<int> l, r;
  for (int i = 0; i < c.size(); i++) {
    if (c[i] & (1 << dep))
      l.push_back(c[i]);
    else
      r.push_back(c[i]);
  }
  if (!l.size())
    return dfs(dep - 1, r);
  else if (!r.size())
    return dfs(dep - 1, l);
  else
    return (1 << dep) + min(dfs(dep - 1, l), dfs(dep - 1, r));
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", a + i), v.push_back(a[i]);
  printf("%d", dfs(30, v));
  return 0;
}
