**Problem Statement:**

You are given an array and q queries which contains 2 positions in the array l and r.

You need to compute the following sum over q queries.

Array is 1-Indexed

**Input:**

The first line of input contains T test cases.

The first line of each test case contains the number of elements in the array.

The second line of each test case contains the elements of the array.

The third line of each test case contains Q queries.

The final line of each test case contains the 2 *Q elements where the first element contains l and second element contains r.

**Output:**

For each test case, print the required sum values in a single line seprated by blank spaces. Print the output of each test case in a new line.

**Constraints:**

1 <= T <= 100

1 <= N <= 1000

0 <= Arr[i] <= 10^6

1 <= Q <= 1000

1 <= l <= r <= N

** Example:**

**Input:**

1

4

1 2 3 4

2

1 4 2 3

**Output:**

10 5

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

d_Coder00 | 134 |

dungeon_master1299 | 126 |

Astikeysingh | 120 |

rajendrashekhawat063 | 115 |

kaustavbhattachaarya | 111 |

Pulkit__Sharma__ | 646 |

Anirban166 | 531 |

abducodes | 501 |

Found_me | 454 |

Yo_Nehru | 404 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4559 |

Login to report an issue on this page.