x = input().split()
y = input().split()




spuys_of_sums = [0]
spys = []
for i in range(len(y)):
    spuys_of_sums.append(int(y[i]))
    spys.append((int(y[i])))
for ind in range(len(y)):

    for ind1 in range(ind,len(y)):
        new_prv = 0
        if y[ind] != y[ind1]:
            new_prv = int(y[ind]) + int(y[ind1])
        if new_prv !=0:
            if new_prv not in spuys_of_sums:

                spuys_of_sums.append(new_prv)
last = 0
for i in range(len(spys)):
    last += spys[i]
spuys_of_sums.append(last)

res = 0
new_bit = 0
for bit in range(len(spuys_of_sums)):

    new_bit = new_bit | spuys_of_sums[bit]

print(new_bit)







