inlinevoidinsert(int x) { int now = 1; for (int i = lim; i; i >>= 1) { if (ch[now][!!(x & i)]) now = ch[now][!!(x & i)]; else ++num[now], now = ch[now][!!(x & i)] = ++cnt; } }
intquery(int x, int k) { if (!num[x]) return0; int ans = 1e9; if (ch[x][0]) ans = std::min(ans, query(ch[x][0], k >> 1)); if (ch[x][1]) ans = std::min(ans, query(ch[x][1], k >> 1)); return ((num[x] == 1) ? ans : (ans + k)); }
inlineintread() { int x = 0; char ch = getchar(); while (ch > '9' || ch < '0') ch = getchar(); while (ch <= '9' && ch >= '0') x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar(); return x; }
intmain() { n = read(); for (int i = 1; i <= n; i++) a[i] = read(), insert(a[i]); printf("%d\n", query(1, lim)); return0; }