N=int(input()) A=map(int,input().split()) ans=1 while 1: ok=1 for a in A: if a+ans!=a^ans: ok=0 break if ok: print(ans) exit() ans<<=1