N = int(input()) A = list(map(int,input().split())) M = (1 << 63) - 1 for R in range(N): M &= ~A[R] print(M & -M)