QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 128 MB Total points: 10

#6579. Little Marketplace

统计

Little Bytec spends his holidays at Grandma Bytegranny. Every morning Grandma goes to the little marketplace to buy various products. The boy quickly noticed an interesting regularity: every day his grandmother spends an amount expressed by an odd integer on her shopping. Bytec soon found out that this regularity is characteristic to all Byteonian grandmothers.

Every day Bytegranny buys not more than one item of each of the $n$ products available in the market. Thrifty grandma does not want to do her shopping carrying too much money with her. One day she asked Bytec for a hint of how much money she needs to take, in case she wants to purchase exactly $k$ products. Unfortunately, Bytec does not know which products grandmother wants to buy, so the amount taken must be sufficient for any $k$ items (and that their total cost would be an odd number). The same situation repeated itself several times. Bytec then decided to approach the problem methodically and write a program that, provided all the prices of products available on the market, will answer grandmother's questions.

Input

The first line of input contains one integer $n$ ($1 \le n \le 1\,000\,000$) denoting the number of products available at the market. The second line contains $n$ integers from the range $[1,10^9]$, denoting the prices of individual products. The third line contains one integer $m$ ($1 \le m \le 1\,000\,000$) denoting the remaining number of days that Bytec will stay at Grandma's place. Each of the following $m$ lines contains one integer $k_i$ ($1 \le k_i \le n$), denoting the number of products that grandma is going to buy on a given day.

Output

Your program should output $m$ lines. In the $i$-th line (for $i=1,\ldots,m$) one integer should be written, indicating the maximum odd price total for $k_i$ products. In case it is not possible to determine $k_i$ products, such that their total price would be represented by an odd number, the $i$-th output line should contain the number $-1$.

Example

Input

4
1 2 3 4
3
2
3
4

Output

7
9
-1
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.