from bisect import bisect_left max2 = lambda x,y: x if x > y else y min2 = lambda x,y: x if x < y else y def solve(a): a.sort() def rec(d,l,r): if l + 1 == r or d == 0: return 0 i = a[l]&(-1 << d)|(1<<(d-1)) m = bisect_left(a,i) if l == m or r == m: return rec(d-1,l,r) return min2(rec(d-1,l,m),rec(d-1,m,r))|(1<<(d-1)) return rec(32,0,len(a)) n = int(input()) a = list(map(int,input().split())) print(solve(a))