EIPFS2 - Range Sum Query - Immutable

Xem dạng PDF

Gửi bài giải

Điểm: 1,00 (OI)
Giới hạn thời gian: 1.0s
Giới hạn bộ nhớ: 256M
Input: stdin
Output: stdout

Dạng bài

Given an integer array nums and multiple queries. Each query contains two indices left and right. Your task is calculating the sum of the elements of nums between indices left and right inclusive.

Input

The first line contains two integers n and q which are the length of nums and the number of queries, relatively. The second line contains n integers which are the elements of nums. Each of the next q lines contains two integers left and right.

Output

Output q lines. Each line contains an integer representing the corresponding sum

Example

Input:
5 2
2 -1 2 5 4
1 1
0 2
Output:

` -1 3


Bình luận

Hãy đọc nội quy trước khi bình luận.


Không có bình luận tại thời điểm này.