Given a sequence of $N$ integers ($1$-indexed), answer $Q$ queries: each query $(i, j)$ asks for the sum of $A_i + A_{i+1} + \dots + A_j$.
Input
First line $N$ and $Q$; second line $N$ integers ($-1000 \le A_i \le 1000$); then $Q$ lines each with $i$, $j$ ($1 \le i \le j \le N$).
Output
Print each query's sum on its own line.
Example 1
Input
6 3 5 4 3 2 -1 8 1 6 5 5 2 5
Output
21 -1 8
Discussion
Threads about this problem. Spoilers are collapsed; wrap hints in
||double bars||.No discussion yet. Start a thread if something here needs explaining.