CF280B.Maximum Xor Secondary

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Bike loves looking for the second maximum element in the sequence. The second maximum element in the sequence of distinct numbers x1,x2,...,xkx_{1},x_{2},...,x_{k} (k>1) is such maximum element xjx_{j} , that the following inequality holds: .

The lucky number of the sequence of distinct positive integers x1,x2,...,xkx_{1},x_{2},...,x_{k} (k>1) is the number that is equal to the bitwise excluding OR of the maximum element of the sequence and the second maximum element of the sequence.

You've got a sequence of distinct positive integers s1,s2,...,sns_{1},s_{2},...,s_{n} (n>1) . Let's denote sequence sl,sl+1,...,srs_{l},s_{l+1},...,s_{r} as s[l..r]s[l..r] (1<=l<r<=n) . Your task is to find the maximum number among all lucky numbers of sequences s[l..r]s[l..r] .

Note that as all numbers in sequence ss are distinct, all the given definitions make sence.

输入格式

The first line contains integer nn (1<n<=10^{5}) . The second line contains nn distinct integers s1,s2,...,sns_{1},s_{2},...,s_{n} (1<=si<=109)(1<=s_{i}<=10^{9}) .

输出格式

Print a single integer — the maximum lucky number among all lucky numbers of sequences s[l..r]s[l..r] .

输入输出样例

  • 输入#1

    5
    5 2 1 4 3
    

    输出#1

    7
    
  • 输入#2

    5
    9 8 3 5 7
    

    输出#2

    15
    

说明/提示

For the first sample you can choose s[4..5]=4,3s[4..5]={4,3} and its lucky number is (4 xor 3)=7(4 xor 3)=7 . You can also choose s[1..2]s[1..2] .

For the second sample you must choose s[2..5]=8,3,5,7s[2..5]={8,3,5,7} .

首页