N = int(input()) A = list(map(int, input().split())) x = 0 for a in A: x |= a x = ~x ans = x & -x print(ans)