CSES - Missing Coin Sum Queries
  • Time limit: 1.00 s
  • Memory limit: 512 MB

You have nn coins with positive integer values. The coins are numbered 1,2,,n1,2,\dots,n.

Your task is to process qq queries of the form: "if you can use coins aba \dots b, what is the smallest sum you cannot produce?"

Input

The first input line has two integers nn and qq: the number of coins and queries.

The second line has nn integers x1,x2,,xnx_1,x_2,\dots,x_n: the value of each coin.

Finally, there are qq lines that describe the queries. Each line has two values aa and bb: you can use coins aba \dots b.

Output

Print the answer for each query.

Constraints

  • 1n,q21051 \le n, q \le 2 \cdot 10^5
  • 1xi1091 \le x_i \le 10^9
  • 1abn1 \le a \le b \le n

Example

Input:

5 3
2 9 1 2 7
2 4
4 4
1 5

Output:

4
1
6

Explanation: First you can use coins [9,1,2][9,1,2], then coins [2][2] and finally coins [2,9,1,2,7][2,9,1,2,7].