You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
'''Given an array of integers, answer queries of the form: [i, j] : Print the sum of array elements from A[i] to A[j], both inclusive.
Input Format
First line of input contains N - size of the array. The next line contains N integers - elements of the array. The next line contains Q - number of queries. Each of the next Q lines contains 2 space separated indexes: i and j.
Constraints
30 points
1 <= N,Q <= 10000
70 points
1 <= N,Q <= 500000
General Constraints
-109 <= A[i] <= 109
0 <= i <= j <= N-1
Output Format
For each query, print the sum of array elements from A[i] to A[j], both inclusive, separated by newline.