| Author: | Pavel Mesenev | Time limit: | 2 sec | |
| Input file: | Standard input | Memory limit: | 256 Mb | |
| Output file: | Standard output |
You are given an array a0, a1, …, an − 1 of integers and q queries. Each query is a pair (l, r) with 0 ≤ l ≤ r ≤ n − 1; answer with al + al + 1 + … + ar.
The first line contains two integers n and q. The second line contains n space-separated integers a0… an − 1. Each of the next q lines contains two integers l and r.
Print q lines: the answer to each query, in order.
1 ≤ n, q ≤ 2 ⋅ 105
− 109 ≤ ai ≤ 109
Every answer fits into a signed 64-bit integer.
| No. | Standard input | Standard output |
|---|---|---|
| 1 |
|
|
| 2 |
|
|