while True:
    try:
        n,q = map(int,input().split())
        nums = list(map(int,input().split()))
        dp = [0]*n
        dp[0] = nums[0]
        for i in range(1,n):
            dp[i] = dp[i-1] + nums[i]
        for j in range(q):
            l,r = map(int,input().split())
            if 0 <= l <= n and 0 <= r <= n and l <= r:
                result = dp[r-1] - dp[l-1] + nums[l-1]
                print(result)
    except:
        break