# https://yukicoder.me/problems/no/1219 from collections import deque def main(): N = int(input()) A = list(map(int, input().split())) answer = 0 for k in range(40): x = 2 ** k count = [0, 0] for a in A: if (1 << k) & a > 0: count[1] += 1 else: count[0] += 1 if count[0] > 0 and count[1] > 0: answer += x print(answer) if __name__ == "__main__": main()