n=int(input()) a=list(map(int,input().split())) ans=0 for x in a:ans|=x for i in range(64): if not (ans>>i)&1: print(2**i) exit()