CSES - Datatähti Open 2019 - Sunset
  • Time limit: 1.00 s
  • Memory limit: 512 MB

There are nn skyscrapers in a row. The sun illuminates some of the skyscrapers from the left: a skyscraper is in the sun if it is higher than any skyscraper to the left.

Your task is to process qq queries where each query has some range [a,b][a,b]. If we assume that only the skyscrapers in the range [a,b][a,b] exist, how many of them are in the sun?

Input

The first input line has two integers nn and qq: the number of skyscrapers and queries. The skyscrapers are numbered 1,2,,n1,2,\dots,n.

The second line has nn integers h1,h2,,hnh_1, h_2, \dots, h_n: the heights of the skyscrapers.

Finally, there are qq lines, each having two integers aa and bb (1abn1 \le a \le b \le n): the range of the query is [a,b][a,b].

Output

For each query, print one integer: the number of skyscrapers in the sun.

Example

Input:

5 3
4 1 2 2 3
1 5
2 5
3 4

Output:

1
3
1

Subtask 1 (16 points)

  • 1n,q20001 \leq n, q \leq 2000
  • 1hi1091 \leq h_{i} \leq 10^9

Subtask 2 (35 points)

  • 1n1051 \leq n \leq 10^5
  • 1q21051 \leq q \leq 2 \cdot 10^5
  • 1hi1001 \leq h_{i} \leq 100

Subtask 3 (49 points)

  • 1n1051 \leq n \leq 10^5
  • 1q21051 \leq q \leq 2 \cdot 10^5
  • 1hi1091 \leq h_{i} \leq 10^9