import sys sys.setrecursionlimit(10**8) N = int(input()) A = list(map(int, input().split())) def dfs(data): m = 0 for a in data: m = max(m, a.bit_length()) if m == 0: return 0 large = [] small = [] for a in data: b = a.bit_length() if b == m: large.append(a ^ (1 << (m-1))) else: small.append(a) res = dfs(large) if small: res = min(res, dfs(small)) res += 1 << (m-1) return res print(dfs(A))