n = int(input())
arr = list(map(int, input().split()))
otvet = sum(arr)
for i in arr:
    otvet |= i
print(otvet)