J2. It's Raining Cats and Corgis (Hard Version)
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

This is the hard version of the problem. The only difference between the two versions is the constraint on $$$x$$$. In this version, $$$x$$$ could be up to $$$10^5$$$.

It's raining cats and corgis! ... and a whole bunch of other random animals.

As a zoology-meteorology-geology triple major, you immediately rush to the field to study the phenomenon. The field is an array of $$$N$$$ positions, where the $$$i^{th}$$$ position has elevation $$$h_i$$$.

As you observe the unusual precipitation of animals, you notice that the animals fall from the sky and stack on top of each other. Each animal adds $$$1$$$ unit of elevation to the position where it lands. Animals continue to stack on top of each other until all valleys in the landscape are filled. Formally, a valley exists if there exist positions $$$i, j, k$$$ such that $$$1 \leq i \lt j \lt k \leq N$$$ and $$$h_i \gt h_j \lt h_k$$$ (Visual example provided below).

You wonder that if you increase the height of the landscape at position $$$i$$$ by $$$x$$$ units, how many animals will fill the resulting landscape.

Input

The first line of input contains 2 space-separated integers $$$N, Q \ (1 \leq N, Q \leq 10^5) - $$$ the size of the landscape and the number of queries to process, respectively.

The second line of input contains $$$N$$$ integers $$$h_i \ (0 \leq h_i \leq 10^5)$$$ separated by spaces, representing the initial elevation at the $$$i^{th}$$$ position in the landscape array.

Each of the following $$$Q$$$ lines contains two integers $$$p_i \ (1 \leq p_i \leq N)$$$ and $$$x_i \ (1 \leq x_i \leq 10^5)$$$, representing the position in the landscape array where the elevation will be increased by $$$x$$$ units.

Note: The changes made in each query should be preserved and taken into account when processing subsequent queries.

Output

Please output $$$Q$$$ lines, where the $$$i^{th}$$$ line contains the answer to the $$$i^{th}$$$ query.

Examples
Input
10 4
2 1 4 4 5 2 3 4 5 3
3 1
7 1
4 1
5 1
Output
8
7
6
6
Input
5 4
0 5 0 5 0
2 1
4 1
3 1
1 1
Output
5
6
5
5
Input
6 2
0 0 0 0 0 0
2 1
4 1
Output
0
1
Note