#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
const int max_base = 32;
long long val[32 * maxn];
int ch[32 * maxn][2];
int tol = 0;
int a[maxn];
void init() {
  tol = 1;
  ch[0][0] = ch[1][0] = 0;
}
void insert(long long x) {
  int u = 0;
  for (int i = max_base; i >= 0; i--) {
    int v = (x >> i & 1);
    if (!ch[u][v]) {
      ch[tol][1] = ch[tol][0] = 0;
      val[tol] = 0;
      ch[u][v] = tol++;
    }
    u = ch[u][v];
  }
  val[u] = x;
}
int query(long long x) {
  int u = 0;
  int ans = 0;
  for (int i = max_base; i >= 0; i--) {
    int v = (x >> i) & 1;
    if (ch[u][v ^ 1]) ans += (1 << i);
    u = ch[u][v];
  }
  return ans;
}
int main() {
  init();
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    insert(a[i]);
  }
  int ans = INT_MAX;
  for (int i = 0; i < n; i++) ans = min(ans, query(a[i]));
  printf("%d\n", ans);
  return 0;
}
