import sys readline = sys.stdin.readline N = int(readline()) A = list(map(int,readline().split())) dp = [0] * (1 << N) # dp[S] = 集合Sを使用済みのときの最大戦闘力 for status in range(1 << N): for i in range(N): # 一人目の選択 if (status >> i) & 1: continue for j in range(N): if (status >> j) & 1: continue xor = A[i] ^ A[j] next_status = status | (1 << i) | (1 << j) if dp[next_status] < dp[status] + xor: dp[next_status] = dp[status] + xor print(dp[-1])