#include <bits/stdc++.h>
using namespace std;
int n;
const int maxn = 1e5 + 5;
int son[maxn << 5][2];
int t[maxn << 5];
int rt = 1;
int tot = 1;
void add(int x) {
  int now = rt;
  for (int i = 30; i >= 0; i--) {
    if (x & (1 << i)) {
      if (son[now][1] == 0) son[now][1] = ++tot;
      now = son[now][1];
    } else {
      if (son[now][0] == 0) son[now][0] = ++tot;
      now = son[now][0];
    }
  }
  t[now] = 1;
}
int dfs(int x, int dep) {
  if (t[x]) return 0;
  if (!son[x][0])
    return dfs(son[x][1], dep - 1);
  else if (!son[x][1])
    return dfs(son[x][0], dep - 1);
  else {
    int tt = min(dfs(son[x][0], dep - 1), dfs(son[x][1], dep - 1));
    return (1 << dep) + tt;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    add(x);
  }
  printf("%d", dfs(1, 30));
  return 0;
}
