#Q121. 「一本通 4.2 例 1」数列区间最大值

「一本通 4.2 例 1」数列区间最大值

Description

Given a sequence of numbers, you will receive MM queries. Each query provides two numbers XX and YY, and you need to determine the maximum number in the interval from XX to YY.

Input Format

The first line contains two integers NN and MM, representing the number of elements and the number of queries, respectively.
The next line contains NN numbers.
The following MM lines each contain two integers XX and YY.

Output Format

Output MM lines, each containing the answer to the corresponding query.

Sample 1

10 2
3 2 4 5 6 8 1 2 9 7
1 4
3 8

5
8

Constraints and Hints

For all data, 1N1051\le N\le 10^5, 1M1061\le M\le 10^6, 1XYN1\le X\le Y\le N. The numbers do not exceed the int range in C/C++.