cnt = [0] * 50 n = int(input()) A = list(map(int, input().split())) max_j = 0 for a in A: for j in range(50): cnt[j] += a & 1 a //= 2 if a == 0: max_j = max(max_j, j) break ans = max(A) for j in range(max_j + 1): if cnt[j] == n: ans -= 2**j print(ans)