- Time limit: 1.00 s
- Memory limit: 512 MB
Teemu has a bank account. On some days he deposits or withdraws money. Some days he doesn't do anything with the account
Now he wonders how much his balance has changed between the morning of day and evening of day
Input
The first line contains a two integer, and , the number of days and the number of queries, respectively.
The second line contains integers, . If , Teemu deposited total of units of money on day. If , Teemu withdrew total of units of money on day. If , Teemu didn't touch the account on day.
Each next lines contain two integers, and , the first and last days of query .
Output
Output lines, one for each query. The line should contain a single integer, the amount of money that the balance has changed between the morning of day (i.e. before any deposits or withdrawals on that day) and the evening of the day (i.e. after all deposits and withdrawals on that day).
Limits
- The balance of the account is always non-negative, i.e. , and at most
Example
Input:
6 10 10 -5 -5 100 50 -100 1 6 1 2 5 6 4 4 4 6 2 3 1 3 3 4 3 6 2 4
Output:
50 5 -50 100 50 -10 0 95 45 90
Explanation:
query: In the beginning of the first day the balance is 0, and after the last day the balance is 50, hence the difference is 50.
query: In the beginning of the first day the balance is 0, and after the second day the balance is 5 (=10-5), hence the difference is 5.
query: In the beginning of the second last day the balance is 100, and after the last day the balance is 50, hence the difference is -50.
query: In the beginning of the fourth day the balance is 0, and after the fourth day the balance is 100, hence the difference is 100.