There are piles of stones, the
-th of which contains
stones. The tiles are numbered from
to
. Rika and Satoko are playing a game on it.
During each round of the game, Rika chooses some piles from all piles. Let denote the set of all chosen piles as
. Satoko then writes a non-negative integer
. If Rika takes some piles from
with the number of stones among all the taken piles equal to
, she wins the game, while otherwise (Rika cannot find such piles) Satoko wins the game. Note that each tile can be taken at most once during a round, and it is possible that Rika does not pick up any tile (when
).
There are rounds of game in total, and for the
-th round of game Rika will let
be the set of all piles with index between
and
. For each round, Satoko wonders the minimum integer
she can write to win the game. As you are a master of programming, it is your turn to solve the problem!
The first line of input contains two integers
and
, where
is the number of tiles and
is the number of the rounds of the games.
The second line contains
integers
, the
-th of which,
, indicates the number of stones in the tile with index
.
Satoko wants you to compute the answers immediately after Rika chooses the interval, so she uses the following method to encrypt the input. The-th of the next
lines contains two integers
. The chosen index range for the
-th round,
, can be computed by the following formula:
wheredenotes the answer for the
-th round of the game (and thus
is the answer for the previous round). You can assume that
. It is clear that under the given constraints,
holds.
Outputlines, the
-th of which contains a single integer
, denoting the minimum integer
Satoko can choose to win the
-th round of the game.