n=int(input()) A=list(map(int,input().split())) q=0 for i in range(n): q|=A[i] ans=(q^(q+1)) ans+=1 ans=ans>>1 print(ans)