import Foundation
let input = readLine()!.components(separatedBy: " ")
let N = Int(input[0])!, M = Int(input[1])!
let numbers = ["0"] + readLine()!.components(separatedBy: " ")
var sumArray = [0]
for i in 1...N {
sumArray.append(sumArray[i-1] + Int(numbers[i])!)
}
for i in 0..<M {
let range = readLine()!.components(separatedBy: " ")
print(sumArray[Int(range[1])!] - sumArray[Int(range[0])! - 1])
}