You are given an array with
n integers
ai and
m queries. Each query is described by two integers
(lj,rj).
Let's define the function
. The function is defined for only
u≤v.
For each query print the maximal value of the function
f(ax,ay) over all
lj≤x,y≤rj, ax≤ay.
Output
For each query print the value
aj on a separate line − the maximal value of the function
f(ax,ay) over all
lj≤x,y≤rj, ax≤ay.
Examples
Output
10
21313
21313
21313
21313
21313
21312
21313
21313
21313
21313
2314
2315
2315
214
215
323
1
323
322