#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e6 + 10;
const long long mod = 1e9 + 7;
int n, m, t;
int cnt, num[maxn][2];
int ans;
int b[40];
void add() {
  int pre = 0;
  for (int i = 0; i <= 31; i++) {
    int x = b[i];
    if (num[pre][x] == 0) num[pre][x] = ++cnt;
    pre = num[pre][x];
  }
}
void dfs(int d, int pre, int sum) {
  if (d == -1) {
    ans = min(sum, ans);
    return;
  }
  if (num[pre][0] && num[pre][1]) {
    dfs(d - 1, num[pre][0], sum + (1 << d));
    dfs(d - 1, num[pre][1], sum + (1 << d));
  } else {
    if (num[pre][0]) dfs(d - 1, num[pre][0], sum);
    if (num[pre][1]) dfs(d - 1, num[pre][1], sum);
  }
}
void solve(int x) {
  int sum = 31;
  memset(b, 0, sizeof b);
  while (x) {
    b[sum--] = x % 2;
    x /= 2;
  }
  add();
}
int main() {
  cnt = 0;
  scanf("%d", &n);
  int x;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    solve(x);
  }
  ans = 1 << 30;
  dfs(31, 0, 0);
  printf("%d\n", ans);
  return 0;
}
