N=int(input()) A=list(map(int, input().split())) if N>15: print(2**16-1) exit() from collections import deque D=[0]*(2**16) D[0]=1 d=deque() d.append(0) def f(x): return x//2+(2**15)*(x%2) for i in range(N): nd=deque() while d: now=d.popleft() a=A[i] nd.append(now) for j in range(16): dd=now|a if D[dd]==0: D[dd]=1 nd.append(dd) a=f(a) d=nd ans=0 for i in range(2**16): if D[i]==1: ans=max(ans,i) print(ans)