#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int trie[5000005][2];
int n, cnt;
inline int read() {
  int t = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    t = (t << 3) + (t << 1) + (ch ^ 48);
    ch = getchar();
  }
  return t;
}
inline void write(int t) {
  if (t > 9) {
    write(t / 10);
  }
  putchar(t % 10 + '0');
}
inline void insert(int t) {
  int pos = 0;
  for (int i = 29; i >= 0; i--) {
    int x = (t >> i) & 1;
    if (!trie[pos][x]) {
      trie[pos][x] = ++cnt;
    }
    pos = trie[pos][x];
  }
}
inline int solve(int t, int cur) {
  if (t == -1) {
    return 0;
  }
  if (!trie[cur][0]) {
    return solve(t - 1, trie[cur][1]);
  } else if (!trie[cur][1]) {
    return solve(t - 1, trie[cur][0]);
  } else {
    return (1 << t) +
           min(solve(t - 1, trie[cur][0]), solve(t - 1, trie[cur][1]));
  }
}
int main() {
  n = read();
  while (n--) {
    insert(read());
  }
  write(solve(29, 0));
  putchar(10);
  return 0;
}
