n = int(input()) *a, = map(int,input().split()) def dfs(k,v): if k==0: return v c = 0 idx = (k&-k).bit_length() - 1 k ^= 1<>i&1: c = max(c,dfs(k^(1<