Sometimes we need to perform operations on pairs of binary numbers. If we have two numbers a and b, we might want to have all the bits set to 0s except the ones that are 1 in both a and b (this corresponds to an AND operation). We might otherwise want to have all ones in positions where either a or b have a 1 there (this corresponds to an OR operation).

a

b

a & b (AND)

a | b (OR)

a ^ b (XOR)
exclusive OR

binary and decimal representations

binary and decimal representations

1 if both and are 1 and 0 otherwise

1 if either or are 1 and 0 otherwise

1 if bits are different and 0 otherwise

110 (6)

101 (5)

100 (4)

111 (7)

011 (3)

100111 (39)

010100 (20)

100 (4)

110111 (55)

110011 (51)

Challenge

Given n integers, you are asked to find 2 of those that after applying OR to them would result in the largest number.

Input

The first line of the input contains a single integer n (1 β€ n β€ 1000).

The next line contains n space-separated integers (1 β€ β€ ).

Output

The output should contain the largest value you can obtain by applying an OR operation on 2 values from the given numbers.