N = int(input()) A = list(map(int, input().split())) dp = [0] * (1 << N) for S in range(1 << N): for i in range(N): if S & (1 << i): continue for j in range(i + 1, N): if S & (1 << j): continue dp[S | (1 << i) | (1 << j)] = max( dp[S | (1 << i) | (1 << j)], dp[S] + (A[i] ^ A[j]) ) print(dp[-1])