package main
import "fmt"
const N = 100010
var n, m int
func main () {
a := make([]int, N)
s := make([]int, N)
fmt.Scanf("%d%d", &n, &m)
for i := 1; i <= n; i ++ {
fmt.Scanf("%d",&a[i])
}
for i := 1; i <= n; i ++ {
s[i] = s[i-1] + a[i]
}
for ; m >0; m -- {
var l, r int
fmt.Scanf("%d%d", &l, &r)
fmt.Println(s[r]-s[l-1])
}
}
难得有用go写的