Range Sum Queries

View as PDF

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

You are given integers and queries.

The integers, stored in an array, will be 1-indexed.

The query format will be: a b, asking the for the sum of to .

Input Specification

The first line will contain an integer .

The next line will contain integers .

The third line of input will contain .

The next lines will contain integers and .

Output Specification

There will be lines of output, each answering the query of a b.

Sample Input 1

5
1 2 3 6 5
4
1 2
3 4
5 5
1 5

Sample Output 1

3
9
5
17