n = int(input()) A = list(map(int, input().split())) if n >= 16: print((1 << 16) - 1) exit() se = {0} for a in A: nex = set() cand = set() for _ in range(16): cand.add(a) t = a & 1 a >>= 1 if t: a |= 1 << 15 for a in cand: for b in se: nex.add(a | b) se = nex print(max(se))