#include <bits/stdc++.h>
using namespace std;
int const maxn = 4e6;
int tr01[maxn][2], x;
int len, check[maxn], n, tot;
void insert(int x) {
  int ex, v = 0;
  for (int i = 29; i >= 0; i--) {
    ex = !!(x & (1 << i));
    if (tr01[v][ex])
      v = tr01[v][ex];
    else {
      tr01[v][ex] = ++tot;
      v = tot;
    }
  }
}
void init() {
  tot = 0;
  memset(tr01, 0, sizeof(tr01));
}
int work(int x, int wei) {
  if (!tr01[x][0] && !tr01[x][1]) return 0;
  if (tr01[x][0] == 0) return work(tr01[x][1], wei - 1);
  if (tr01[x][1] == 0) return work(tr01[x][0], wei - 1);
  return (1 << wei) + min(work(tr01[x][1], wei - 1), work(tr01[x][0], wei - 1));
}
int main() {
  scanf("%d", &n);
  init();
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    insert(x);
  }
  printf("%d\n", work(0, 29));
  return 0;
}
