It's Halloween! Graham the Ghost is very excited for this spooky celebration. Of course, Graham wants to maximize the number of sweets he snags from his neighborhood. Of course, he also asks you for help in planning these routes.
The neighborhood is made of houses in a horizontal line. Each house can be represented by an integer () where the th house means the th house from the left. Each house has an integer , which represents the number of candies house would give to Graham. You know this information from being an insider in the trick-or-treating industry.
However, top secret intel recently uncovered that every even-numbered house is cursed and will take candy from Graham instead of giving it! More precisely, house will give Graham candies if is odd and take candies from him if is even.
Graham has ranges that he plans to trick-or-treat on, and in no small part due to the cursed houses he wants you to precalculate the candy he will get for each range. Can you help Graham make it out of this month without going into crippling candy debt?
Constraints
Subtask 1 [30%]
Subtask 2 [70%]
No additional constraints.
Input Specifications
The first line will contain , the number of houses.
The next line will contain integers (), the candy values for the houses
The next line will contain , the number of ranges Graham wants to precalculate.
The next lines will contain two integers (), the inclusive endpoints of the range. Note that ranges may overlap.
Output Specifications
Output lines, each containing one integer — the number of candies you will get when trick-or-treating at the houses in the specified range.
Sample Input
6
3 3 4 8 1 2
2
1 3
2 6
Sample Output
4
-8
Sample explanation
For the first query, Graham acquires candies. For the second query, Graham acquires candies. Looks like he's going into debt...
Comments