N = int(input()) A = list(map(int,input().split())) import sys sys.setrecursionlimit(10 ** 8) _max = 0 def calc(S = 0,now = 0): global _max if S == (1 << N) - 1: if now > _max: _max = now return for j in range(N): maskj = 1 << j if maskj & S == 0:break b = S ^ maskj for u in range(N): masku = 1 << u if b & masku: calc(b ^ masku,now + A[j] ^ A[u]) calc() print(_max)