SP30947 SGIFT - Sabbir and gifts

Description

Sabbir is a little boy. he went to a gift shop with his mother. there were **n** different types of gifts in the shop . all gifts were attractive to sabbir. he wanted to buy all the gifts which are in price range [![](https://latex.codecogs.com/gif.latex?a&space;\leq&space;p&space;\leq&space;b "a \leq p \leq b")](https://www.codecogs.com/eqnedit.php?latex=a&space;\leq&space;p&space;\leq&space;b) . you are given prices of all the gifts and **a** , **b** . sabbir's mother need your help. please calculate the total amount of price of all gifts of that range for sabbir's mother.

Input Format

in the first line there will be **n .** number of gifts in the shop. in the next line there will be **n** integers **p** $ _{1} $ **, p** $ _{2} $ **, p** $ _{3} $ **... p** $ _{n   } $ denoting price of every gift in the 3rd line there will be **Q** number of queries. next **Q** lines contain two integes **a** and **b** [![](https://latex.codecogs.com/gif.latex?1&space;\leq&space;n&space;\leq&space;10^{5} "1 \leq n \leq 10^{5}")](https://www.codecogs.com/eqnedit.php?latex=1&space;\leq&space;n&space;\leq&space;10^{5}) [](https://www.codecogs.com/eqnedit.php?latex=1&space;\leq&space;n&space;\leq&space;10^{5}) [![](https://latex.codecogs.com/gif.latex?1&space;\leq&space;p_{i}&space;\leq&space;10^{9} "1 \leq p_{i} \leq 10^{9}")](https://www.codecogs.com/eqnedit.php?latex=1&space;\leq&space;p_{i}&space;\leq&space;10^{9}) [](https://www.codecogs.com/eqnedit.php?latex=1&space;\leq&space;p_{i}&space;\leq&space;10^{9}) [![](https://latex.codecogs.com/gif.latex?1&space;\leq&space;Q&space;\leq&space;10^{5} "1 \leq Q \leq 10^{5}")](https://www.codecogs.com/eqnedit.php?latex=1&space;\leq&space;Q&space;\leq&space;10^{5}) [![](https://latex.codecogs.com/gif.latex?1&space;\leq&space;a,b&space;\leq&space;10^{9} "1 \leq a,b \leq 10^{9}")](https://www.codecogs.com/eqnedit.php?latex=1&space;\leq&space;a,b&space;\leq&space;10^{9})

Output Format

print **Q** lines . every line contains one integer , sum of all prices for that range given in the query.