CSES - Subarray Sum Queries II
  • Time limit: 1.00 s
  • Memory limit: 512 MB

You are given an array of nn integers and qq queries. In each query, your task is to calculate the maximum subarray sum in the range [a,b][a,b].

Empty subarrays (with sum 00) are allowed.

Input

The first line contains two integers nn and qq: the number of elements and the number of queries.

Then there are nn integers x1,x2,,xnx_1,x_2,\ldots,x_n: the contents of the array.

Finally there are qq lines that describe the queries. Each line has two integers aa and bb.

Output

Print the answer for each query.

Constraints

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

Example

Input:

8 4
2 5 1 -2 3 -1 -7 1
2 4
2 5
6 7
4 8

Output:

6
7
0
3