1031 - Can you help Bill

Time Limit: 1s Memory Limit: 128MB

Submissions: 79 Solved: 34
Description
Bill is a good student . But he very lazy . One day his teacher give him a sequence of number {an} and ask him to calculate the sum of number indexed from i to j(index start from 1). When i and j changed there will be many problems. As Bill is very lazy , he want to do work as little as possible . So he ask you to solve some for him.
Input
Test data contain multiple cases. For each case: The 1st line contain 2 number n and m indentify Bill's teacher give him n numbers and m problems(n<=1000, m<=1000). Followed by m line to tell the problems. For each line, The first number will be 0 or 1. If it is 0 the problem have not solved, otherwise it`s solved already. following 2 integers i and j as descripted above. If the first number is 1 there will be one more number to tell the sum. You can ensure that all the sums can be stored in 32-bit integers.
Output
For each problem have not solved you should output a number to tell the sum . If he must calculate the problems himself you should print a "sorry" instead. Note that you read and solve the problems one by one in the given order, once you failed a problem, you shall not look back.
Sample Input
5 6
1 1 3 78
1 1 2 67
0 3 3
1 3 5 89
0 1 1
0 4 5
Sample Output
11
sorry
78
Hint
Source
Wu Shaoliang