N=int(input()) A=list(map(int,input().split())) X=1 while True: flag=1 for a in A: if X+a!=X^a: flag=0 if flag: exit(print(X)) else: X<<=1