시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 512 MB108513749.333%

문제

The sale bin of Big Box Bargains contains n products in a row. The ith item has price ai per unit. There is no limit to the quantity of any item.

There are q customers who will enter the store to buy items. The ith customer has vi dollars, starts at item li and walks to the right to item ri (inclusive), one item at a time.

Each time they encounter an item, they will buy as many units of the item as they can afford.

You are now wondering, for each customer, how much money they will have left after buying items.

입력

The first line of input contains two space-separated integers n and q (1 ≤ n, q ≤ 200,000).

The next line of input contains n space-separated integers ai (1 ≤ ai ≤ 1018).

Each of the next q lines contains three space-separated integers vi (1 ≤ vi ≤ 1018), li , and ri (1 ≤ li ≤ ri ≤ n).

출력

For each of the q customers, print, on a single line, a single integer indicating the remaining amount of money after shopping.

예제 입력 1

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

예제 출력 1

2
0
1