n = int(input()) A = list(set(map(int, input().split()))) def dfs(A, t): if len(A) == 1 or t == -1: return 0 L = [] R = [] for a in A: if a >> t & 1: L.append(a ^ (1 << t)) else: R.append(a) if L and R: return min(dfs(L, t - 1), dfs(R, t - 1)) | (1 << t) elif L: return dfs(L, t - 1) else: return dfs(R, t - 1) print(dfs(A, 29))