Music Notes I
GJ will teach your cows how perform a song. The song consists of
Cows have lost interest in the song, because they feel it is long and boring.Therefore, to be sure that their cows are paying attention, GJ makes them
As an example, consider a song with these specifications: the note 1 lasts 2 times, the note 2 lasts 1 time and the note 3 lasts 3 times.
NOTE 1 1 2 3 3 3
+--+--+--+--+--+--+
TIME 0 1 2 3 4 5
Input specification
Line 1: Two space-separated integers N and Q.
Lines 2 .. N+1: The line
Lines N + 2 ..
Output specification
The answer to each question.
Sample input
3 5
2
1
3
2
3
4
0
1
Sample output
2
3
3
1
1
Comments