def dfs(d, a): if len(a) == 1: return 0 a0 = [] a1 = [] b = 1 << d for n in a: if n & b: a1.append(n) else: a0.append(n) if not a0 or not a1: if d == 0: return 0 return dfs(d - 1, a) else: if d == 0: return 1 return b + min(dfs(d - 1, a0), dfs(d - 1, a1)) def solve(N, A): return dfs(30, A) def main(): N = int(input()) A = list(map(int, input().split())) print(solve(N, A)) if __name__ == '__main__': main()