N = int(input()) A = list(map(int, input().split())) ans = 0 for i in range(64): if set((a >> i) & 1 for a in A) == {0, 1}: ans += 1 << i print(ans)