#P1208F. Bits And Pieces
Bits And Pieces
No submission language available for this problem.
Description
You are given an array of integers.
You need to find the maximum value of over all triplets such that .
Here denotes the bitwise AND operation, and denotes the bitwise OR operation.
The first line of input contains the integer (), the size of the array .
Next line contains space separated integers , , ..., (), representing the elements of the array .
Output a single integer, the maximum value of the expression given in the statement.
Input
The first line of input contains the integer (), the size of the array .
Next line contains space separated integers , , ..., (), representing the elements of the array .
Output
Output a single integer, the maximum value of the expression given in the statement.
Samples
Note
In the first example, the only possible triplet is . Hence, the answer is .
In the second example, there are possible triplets:
- , value of which is .
- , value of which is .
- , value of which is .
- , value of which is .
The maximum value hence is .