N = int(input()) A = list(map(int,input().split())) bit = 0 for i in range(N): bit |= A[i] ans = 1 while ans & bit: ans <<= 1 print(ans)