import sys sys.setrecursionlimit(10**9) N = int(input()) A = list(map(int, input().split())) ans = 0 def shift(x): return x // 2 + 2**15 * (x % 2) def dfs(v, i): global ans if i == N: # if ans < v: # print(bin(v)) ans = max(v, ans) return # p = 0 # while 2**p < A[i]: # p += 1 dfs(v | A[i], i + 1) x = A[i] # print(p) for j in range(15): x = shift(x) # print(f"x = {x}, v={v}") dfs(v | x, i + 1) dfs(0, 0) print(ans)