import sys from itertools import combinations input = sys.stdin.readline N = int(input()) power = list(map(int, input().split())) dp = [0]*(1 << N) for bitset in range(1 << N): for (p1, power1), (p2, power2) in combinations(enumerate(power), r=2): if ((1 << p1) | (1 << p2)) & bitset: continue dp[bitset | (1 << p1) | (1 << p2)] = max( dp[bitset | (1 << p1) | (1 << p2)], dp[bitset] + (power1 ^ power2) ) print(dp[-1])