Vincent Massey SS - 2014 Senior Contest #1
Lil' Jami is playing with a set of cups numbered and an infinite number of stones. Each cup initially has stones in it. Since he has an infinite amount of free time, Lil' Jami plays a game where he repeatedly adds a stone to a cup. He does this times.
Following this, there will be queries of the form a b
. For each query, find the sum of the stones in cups numbered .
Input Specification
The first line will contain the integers and separated by a space.
The next lines will each contain a single integer meaning to add a stone to the cup with index (for ).
The next line will contain the single integer .
The next lines will contain two space-separated integers and .
Output Specification
For each query, print the sum of the number of stones in each of the cups in the range , inclusive.
Sample Input
5 3
1
1
2
2
0 2
2 4
Sample Output
3
1
Comments