n = int(input())
a = list(map(int, input().split()))
res = sum(a)
for x in a:
    res |= x


print(res)