410279: GYM103999 H for-for-for-for

Memory Limit:256 MB Time Limit:3 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

H. for-for-for-fortime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard 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 $$$v$$$ be an array of $$$n$$$ non-negative integers. Find the maximum value of ($$$v_i$$$ $$$\oplus$$$ $$$v_j$$$) $$$\times$$$ ($$$v_k$$$ + $$$v_l$$$), where $$$1$$$ $$$\le$$$ $$$i < j < k < l$$$ $$$\le$$$ $$$n$$$. Here $$$\oplus$$$ represents the bitwise xor operation.

Help Rares save his GPA!

Input

The first line of the input contains $$$n$$$ ($$$4$$$ $$$\le$$$ $$$n$$$ $$$\le$$$ $$$200000$$$), the size of the given array.

The next line contains $$$n$$$ non-negative integers $$$v_1$$$, $$$v_2$$$, ..., $$$v_n$$$ ($$$0$$$ $$$\le$$$ $$$v_i$$$ $$$\le$$$ $$$2^{30}-1$$$).

Output

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

Scoring
  • For $$$20$$$ points, it is guaranteed that $$$n$$$ $$$\le$$$ $$$200$$$
  • For another $$$20$$$ points, it is guaranteed that $$$n$$$ $$$\le$$$ $$$2000$$$
  • For the last $$$60$$$ points, we have $$$n \leq 200000$$$
ExampleInput
6
12 42 2 0 145 7
Output
6384
Note

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

加入题单

算法标签: