N=int(input()) A=list(map(int, input().split())) a=bin(10**18+1) d=len(a)-2 D=[0]*d for i in A: a=bin(i)[2:] for j in range(len(a)): if a[-1-j]=='1': D[j]=1 for i in range(d): if D[i]==0: print(2**i) exit()