#include <bits/stdc++.h>
using namespace std;
int tmp, n, tr[100005 * 30][2], cnt;
inline void insert(int x) {
  int p = 0, d;
  for (int i = 29; i >= 0; --i) {
    d = (x >> i) & 1;
    if (tr[p][d])
      p = tr[p][d];
    else {
      tr[p][d] = ++cnt;
      p = cnt;
      memset(tr[p], 0, sizeof(tr[p]));
    }
  }
}
int dfs(int p, int d) {
  if (!tr[p][0] && !tr[p][1]) return 0;
  if (!tr[p][0]) return dfs(tr[p][1], d - 1);
  if (!tr[p][1]) return dfs(tr[p][0], d - 1);
  return (1 << d) + min(dfs(tr[p][0], d - 1), dfs(tr[p][1], d - 1));
}
int main() {
  while (~scanf("%d", &n)) {
    cnt = 0;
    memset(tr[0], 0, sizeof(tr[0]));
    for (int i = 1; i <= n; ++i) {
      scanf("%d", &tmp);
      insert(tmp);
    }
    int ans = dfs(0, 29);
    printf("%d\n", ans);
  }
  return 0;
}
