for-for-for-for

Time limit: 3s
Memory limit: 256MB
Input:
Output:

After a tiring practical test at OOP, Rares is faced with a new challenge. He has to solve the following problem, otherwise he will fail the Programming class.

Let vv be an array of nn non-negative integers. Find the maximum value of (vivj)×(vk+vl)(v_i \oplus v_j) \times (v_k + v_l), where 1i<j<k<ln1 \le i < j < k < l \le n. Here \oplus represents the bitwise xor operation.

Help Rares save his GPA!

Input data

The first line of the input contains nn (4n200 0004 \le n \le 200 \ 000), the size of the given array.

The next line contains nn non-negative integers v1v_1, v2v_2, \dots, vnv_n (0vi23010 \le v_i \le 2^{30}-1).

Output data

Output a single number, the maximum value of (vivj)×(vk+vl)(v_i \oplus v_j) \times (v_k + v_l), where 1i<j<k<ln1 \le i < j < k < l \le n.

Constraints and clarifications

  • For 2020 points, it is guaranteed that n200n \le 200;
  • For another 2020 points, it is guaranteed that n2 000n \le 2 \ 000;
  • For the last 6060 points, we have n200 000n \leq 200 \ 000;

Example 1

stdin

6
12 42 2 0 145 7

stdout

6384

Explanation

Rares chooses i=2i=2, j=4j=4, k=5k=5, l=6l=6. The value is (420)×(145+7)=6384(42 \oplus 0) \times (145 + 7) = 6384.

Log in or sign up to be able to send submissions!