Hay

아직 제출이 없습니다시간 제한2초메모리 제한128 MB

문제

Byteasar, a farmer, bought a field of area equal to nn ares, where he intends to sow grass seeds. Mown and dried hay will be used as a fodder for livestock kept on Byteasar's farm.

A mix of nn grass species will be sown in the field -- each species will take up a total of 11 ares. For the ii-th species it is known that its grass blades grow by a_ia\_i centimetres each day, regardless of weather conditions or soil fertility. It is also known that as a result of mowing one are of any grass type by one centimetre, exactly 11 kilogram of hay is obtained.

Byteasar has a mower that can be set in such a way that it cuts grass to any height bb. With this setting each blade of grass higher than bb centimetres will be trimmed down to the height of exactly bb centimetres.

Byteotian law requires that after each grass mowing the amount of hay obtained is to be documented. Byteasar faced a choice: he must either buy a weighing machine, or write a program that based on the dates of mowing and mowers settings, could estimate the weight of the hay obtained after each mowing. The second of these options seemed more convenient and cheaper to him.

We assume that the grass will be sown on day 00 at midnight and always be mown at midnight. We also assume that the time it takes to mow the grass in the field to any height bb is negligible.

입력

The first line of input contains two integers nn and mm (1n,m500,0001\leq n,m\leq 500\\,000), denoting Byteasar's field area in ares (and at the same time the number of grass species sown) and the number of times the grass has been mown. The second line contains a sequence of nn integers a_1,a_2,,a_na\_1, a\_2, \ldots, a\_n (1a_i1061\leq a\_i\leq 10^6) indicating the rate of growth of successive species of grass.

The next mm lines contain the details of how Byteasar mowed the grass: the ii-th mowing is described by two integers d_id\_i and b_ib\_i (1d_i10121\leq d\_i \leq 10^{12}, 0b_i10120\leq b\_i \leq 10^{12}) contained in the ii-th of these lines and indicating that on day d_id\_i Byteasar trimmed the grass to the length of b_ib\_i centimetres. You can assume that this data is listed in chronological order, i.e., d_1<d_2<<d_md\_1 < d\_2 < \ldots < d\_m.

Furthermore, you can also assume that Byteasar would never allow a situation when the grass has height exceeding 101210^{12} centimetres at any place in the field.

출력

The output should contain exactly mm lines. The ii-th of these lines should include a total weight of hay (in kilograms) obtained after the ii-th grass mowing.

힌트

DayBefore mowingAfter mowing
111,2,4,31, 2, 4, 31,1,1,11, 1, 1, 1
222,3,5,42, 3, 5, 42,2,2,22, 2, 2, 2
333,4,6,53, 4, 6, 50,0,0,00, 0, 0, 0
441,2,4,31, 2, 4, 31,2,4,31, 2, 4, 3