There are *n* piles of stones of sizes *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub> lying on the table in front of you.

During one move you can take one pile and add it to the other. As you add pile *i* to pile *j*, the size of pile *j* increases by the current size of pile *i*, and pile *i* stops existing. The cost of the adding operation equals the size of the added pile.

Your task is to determine the minimum cost at which you can gather all stones in one pile. 

To add some challenge, the stone piles built up conspiracy and decided that each pile will let you add to it not more than *k* times (after that it can only be added to another pile). 

Moreover, the piles decided to puzzle you completely and told you *q* variants (not necessarily distinct) of what *k* might equal. 

Your task is to find the minimum cost for each of *q* variants.
The first line contains integer *n* (1 ≤ *n* ≤ 10<sup class="upper-index">5</sup>) — the number of stone piles. The second line contains *n* space-separated integers: *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub> (1 ≤ *a*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">9</sup>) — the initial sizes of the stone piles. 

The third line contains integer *q* (1 ≤ *q* ≤ 10<sup class="upper-index">5</sup>) — the number of queries. The last line contains *q* space-separated integers *k*<sub class="lower-index">1</sub>, *k*<sub class="lower-index">2</sub>, ..., *k*<sub class="lower-index">*q*</sub> (1 ≤ *k*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">5</sup>) — the values of number *k* for distinct queries. Note that numbers *k*<sub class="lower-index">*i*</sub> can repeat.
print("_RANDOM_GUESS_1689176194.389285")# 1689176194.389299