N=int(input()) A=list(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