package main
import "fmt"
func Query(s []int, l, r int) int {
return s[r] - s[l-1]
}
func main() {
var n, m int
fmt.Scanf("%d %d", &n, &m)
num, sums := 0, make([]int, n+1)
for i := 1; i <= n; i++ {
fmt.Scanf("%d", &num)
sums[i] = sums[i-1] + num
}
for i := 0; i < m; i++ {
var l, r int
fmt.Scanf("%d %d", &l, &r)
fmt.Println(Query(sums, l, r))
}
}