Hay
시간 제한2초메모리 제한128 MB
각 잔디 종은 저마다의 일일 성장률로 자라고, m번의 예초마다 높이 b로 깎은 뒤 잘린 길이의 총합을 킬로그램으로 구한다.
문제
Byteasar, a farmer, bought a field of area equal to 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 grass species will be sown in the field -- each species will take up a total of ares. For the -th species it is known that its grass blades grow by 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 kilogram of hay is obtained.
Byteasar has a mower that can be set in such a way that it cuts grass to any height . With this setting each blade of grass higher than centimetres will be trimmed down to the height of exactly 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 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 is negligible.
입력
The first line of input contains two integers and (), 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 integers () indicating the rate of growth of successive species of grass.
The next lines contain the details of how Byteasar mowed the grass: the -th mowing is described by two integers and (, ) contained in the -th of these lines and indicating that on day Byteasar trimmed the grass to the length of centimetres. You can assume that this data is listed in chronological order, i.e., .
Furthermore, you can also assume that Byteasar would never allow a situation when the grass has height exceeding centimetres at any place in the field.
출력
The output should contain exactly lines. The -th of these lines should include a total weight of hay (in kilograms) obtained after the -th grass mowing.