import sys sys.setrecursionlimit(10**6) n = int(input()) a = list(map(int,input().split())) c=[[0,0] for i in range(31)] for i in a: t=bin(i)[2:][::-1] for j in range(len(t)): c[j][int(t[j])] += 1 cnt = 0 for i,j in c: if i + j == 0: break cnt+=1 lis=[] def cal(x,ind): if ind == cnt: lis.append(int(x[::-1],2)) return o,i=c[ind][0],c[ind][1] if o == n: cal(x+'0',ind+1) elif i == n: cal(x+'1',ind+1) else: cal(x+'0',ind+1) cal(x+'1',ind+1) cal('',0) A=10**18 for x in lis: t=0 for i in a: t=max(i^x,t) A=min(A,t) print(A)