Codeforces Round 163 (Div. 2) |
---|
Finished |
You've got an array, consisting of n integers: a1, a2, ..., an. Your task is to quickly run the queries of two types:
The first line contains two integers n and m (1 ≤ n, m ≤ 105), showing, how many numbers are in the array and the number of queries, correspondingly. The second line contains n integers: a1, a2, ..., an (0 ≤ ai ≤ 109) — the initial values of the array elements.
Then m queries follow, one per line:
All numbers in the input are integers.
For each query to calculate the sum print an integer — the required sum modulo 1000000007 (109 + 7).
4 5
5 10 2 1
? 1 2 1
= 2 2 0
? 2 4 3
= 1 4 1
? 1 4 5
25
43
1300
3 1
1000000000 1000000000 1000000000
? 1 3 0
999999986
Name |
---|