#include <bits/stdc++.h>
using namespace std;
struct node {
  int v, zs[2];
} tr[3000005];
int tot = 0, n, dp[3000005], x, u;
void dfs(int p) {
  if (tr[p].v == -1) return;
  int x, y;
  x = tr[p].zs[0];
  y = tr[p].zs[1];
  if (x) dfs(x);
  if (y) dfs(y);
  if (x && y) {
    dp[p] = (1 << tr[p].v) + min(dp[x], dp[y]);
  } else {
    if (x)
      dp[p] = dp[x];
    else
      dp[p] = dp[y];
  }
}
int main() {
  tr[0].v = 29;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    u = 0;
    for (int j = 29; j >= 0; j--) {
      if ((1 << j) & x) {
        if (tr[u].zs[1] == 0) {
          tr[u].zs[1] = ++tot;
          tr[tot].v = j - 1;
        }
        u = tr[u].zs[1];
      } else {
        if (tr[u].zs[0] == 0) {
          tr[u].zs[0] = ++tot;
          tr[tot].v = j - 1;
        }
        u = tr[u].zs[0];
      }
    }
  }
  dfs(0);
  printf("%d\n", dp[0]);
  return 0;
}
