Product Sum Queries

For each query K, sum the products of all K-element subsets of A, counting positions separately, modulo 100003.

Medium6Dynamic programmingCombinatoricsMathNo attempts yetTime limit2sMemory limit512 MB

Problem

You are given a sequence AA of NN numbers. Write a program that answers QQ queries about it.

Each query is a single integer KK. Consider every way of choosing KK elements of AA, take the product of the KK chosen numbers for each way, add all of those products, and print the sum modulo 100003100003.

Choices are distinguished by position. Elements with equal values at different positions give different choices, so the number of ways is always the binomial coefficient (NK)\binom{N}{K}.

Input

The first line contains NN (1N300001 \le N \le 30000).

The second line contains the elements A1,A2,,ANA_1, A_2, \dots, A_N (1Ai1000001 \le A_i \le 100000), separated by spaces.

The third line contains the number of queries QQ (1QN1 \le Q \le N).

Each of the next QQ lines contains one KK (1KN1 \le K \le N).

Output

Print the answer to each query on its own line, in the order the queries are given.

Hint

For A=(2,3,5)A = (2, 3, 5) and K=2K = 2 the choices are {2,3}\{2, 3\}, {2,5}\{2, 5\}, {3,5}\{3, 5\}. The products are 66, 1010, 1515 and the sum is 3131.

For A=(4,4,7)A = (4, 4, 7) and K=2K = 2 there are still three choices, because the two 44s sit at different positions. The products are 1616, 2828, 2828 and the sum is 7272.