p02271 Exhaustive Search_36610
Write a program which reads a sequence A of n elements and an integer M, and outputs "yes" if you can make M by adding elements in A, otherwise "no". You can use an element only once.

You are given the sequence A and q questions where each question contains Mi.

Notes

You can solve this problem by a Burte Force approach. Suppose solve(p, t) is a function which checkes whether you can make t by selecting elements after p-th element (inclusive). Then you can recursively call the following functions:

solve(0, M)
solve(1, M-{sum created from elements before 1st element})
solve(2, M-{sum created from elements before 2nd element})
...

The recursive function has two choices: you selected p-th element and not. So, you can check solve(p+1, t-A[p]) and solve(p+1, t) in solve(p, t) to check the all combinations.

For example, the following figure shows that 8 can be made by A[0] + A[2].

<image>

Constraints

* n ≤ 20
* q ≤ 200
* 1 ≤ elements in A ≤ 2000
* 1 ≤ Mi ≤ 2000

Input

In the first line n is given. In the second line, n integers are given. In the third line q is given. Then, in the fourth line, q integers (Mi) are given.

Output

For each question Mi, print yes or no.

Example

Input

5
1 5 7 10 21
8
2 4 17 8 22 21 100 35


Output

no
no
yes
yes
yes
yes
no
no
n=int(input())
A=list(map(int,input().split()))
q=int(input())
M=list(map(int,input().split()))

pattern=[]

for i in range(2**n):
    s=0
    for j in range(n):
        if i >> j & 1:
            s+=A[j]
    pattern.append(s)
P=set(pattern)

for m in M:
    print('yes' if m in P else 'no')

5
1 5 7 10 21
8
2 4 17 8 22 21 100 35 5
1 5 7 10 21
8
2 4 17 10 22 21 100 35 5
1 5 7 3 21
8
2 4 17 10 22 21 100 42 5
1 5 7 3 21
8
0 4 17 10 22 21 100 42 5
1 5 7 3 21
8
0 4 17 11 22 21 010 42 5
0 5 7 3 21
8
0 4 17 11 22 21 010 42 5
0 5 10 3 21
8
0 4 17 11 22 14 010 42 5
0 5 10 3 21
8
1 4 17 11 22 14 010 42 5
0 5 10 3 21
8
1 4 17 11 22 14 011 42 5
0 5 10 -1 21
8
1 7 17 11 8 14 011 41 5
0 5 13 -1 21
8
1 2 17 11 8 14 011 41 5
1 7 7 10 21
8
2 4 17 10 22 21 100 35 5
1 5 7 10 21
8
2 4 17 10 42 21 100 42 5
1 5 7 3 36
8
2 4 17 10 22 21 100 42 5
0 5 7 3 21
8
0 4 17 11 22 21 100 42 5
1 5 7 3 21
8
0 4 15 11 22 21 110 42 5
0 5 10 3 21
8
0 4 13 11 22 14 010 42 5
0 5 11 3 21
8
1 4 17 11 22 14 010 42 5
0 5 10 3 21
8
1 4 17 11 24 14 011 42 5
0 5 10 3 21
8
1 7 17 13 22 14 011 41 5
0 5 10 -1 21
8
1 7 17 11 8 14 010 41 5
1 7 7 10 21
8
2 4 17 10 22 20 100 35 5
1 5 7 3 36
8
2 4 17 10 22 21 100 60 5
0 7 7 3 21
8
0 4 17 11 22 21 100 42 5
2 5 7 3 21
8
0 4 17 11 22 21 010 74 5
0 5 10 3 40
8
1 8 17 11 22 14 011 42 5
0 5 10 -1 21
8
0 2 17 11 9 14 011 41 5
0 5 13 -1 21
8
0 2 17 11 8 10 011 43 5
1 5 7 3 36
8
2 4 16 10 22 21 100 60 5
1 5 7 3 21
8
0 4 15 11 38 21 110 57 5
0 5 11 3 21
8
2 4 17 11 22 14 000 42 5
1 5 10 -1 21
8
0 2 17 11 9 14 011 41 5
0 7 7 3 21
8
-1 4 17 11 4 21 100 42 5
2 5 7 3 21
8
0 2 17 11 22 34 010 74 5
0 5 11 5 21
8
2 4 17 11 22 14 000 42 5
0 5 10 3 21
8
1 7 7 13 22 16 010 41 5
-1 0 13 -1 21
8
2 2 11 11 8 14 011 41 5
1 5 7 2 36
8
2 5 16 10 22 21 100 60 5
2 5 7 3 17
8
0 4 17 10 26 21 101 72 5
1 5 7 3 21
8
0 4 15 9 38 21 010 57 5
2 5 7 3 21
8
0 2 17 11 36 34 010 74 5
1 6 10 0 21
8
1 6 9 11 22 14 111 41 5
-1 0 13 -1 21
8
2 2 11 11 8 14 111 41 5
2 5 7 3 17
8
0 0 17 10 26 21 101 72 5
1 5 7 3 21
8
0 4 2 9 38 21 010 57 5
0 5 7 3 21
8
0 6 33 11 8 21 001 47 5
1 6 10 0 21
8
1 5 9 11 22 14 111 41 5
0 5 7 3 21
8
0 6 33 11 8 21 000 47 5
0 7 3 5 21
8
-1 1 17 11 5 21 101 42 5
0 5 7 3 21
8
0 0 33 11 2 21 000 47 5
0 5 10 3 40
8
2 7 5 1 22 16 010 41 5
-1 5 10 1 21
8
1 8 31 11 16 14 001 40 5
0 7 1 5 21
8
-1 1 17 11 5 21 101 42 5
0 5 5 3 21
8
0 0 33 11 2 21 000 47 5
0 8 9 0 21
8
0 2 18 3 39 21 011 30 5
1 5 17 -1 21
8
1 2 19 11 17 8 011 76 5
0 5 5 3 21
8
0 0 33 11 0 21 000 47 5
1 5 17 -1 21
8
1 1 19 11 17 8 011 76 5
-2 5 10 2 21
8
2 8 31 11 16 14 001 40 5
1 5 32 -1 21
8
1 1 19 11 17 8 011 76 5
1 5 56 -1 21
8
1 1 19 11 17 8 011 76 5
0 6 9 0 39
8
0 2 18 3 55 21 011 0 5
0 2 1 5 34
8
-1 1 17 11 3 21 100 39 5
0 2 1 5 63
8
-1 0 17 11 3 21 100 39 5
0 6 9 -1 39
8
0 2 18 5 17 21 011 0 5
0 3 9 -1 39
8
0 2 18 5 17 21 011 0 5
0 3 9 -1 22
8
0 2 18 5 17 21 011 0 5
0 3 14 5 10
8
0 0 17 7 62 1 111 13 5
0 3 9 -1 13
8
0 2 18 5 2 21 011 0 5
0 5 14 5 10
8
0 -1 17 7 62 1 111 13 5
0 3 15 -1 13
8
0 2 18 5 2 21 011 0 5
-1 3 15 -1 13
8
0 2 18 5 2 21 011 0 5
0 5 14 5 13
8
-1 -1 17 7 40 1 111 13 5
1 5 7 10 21
8
2 4 17 10 22 14 100 42 5
1 5 11 3 21
8
2 4 17 10 22 21 100 42 5
1 5 7 6 21
8
0 4 17 11 22 21 110 42 5
1 5 13 3 21
8
0 4 17 11 22 21 010 42 5
0 8 13 -1 21
8
1 2 17 11 8 14 011 41 5
1 5 9 3 36
8
2 4 17 10 22 21 100 42 5
1 5 8 3 21
8
0 4 17 10 22 21 101 42 5
1 5 7 3 39
8
0 4 17 11 22 21 010 74 5
0 5 7 3 21
8
0 4 17 11 26 21 010 47 5
-1 5 10 -1 21
8
1 7 17 11 8 14 010 41 5
0 7 4 3 21
8
0 4 17 11 22 21 100 42 5
2 5 7 3 21
8
1 4 17 11 22 21 010 74 5
0 5 11 3 21
8
2 5 17 11 22 14 010 42 5
0 5 10 -1 21
8
0 2 17 11 9 14 011 15 5
1 5 7 10 3
8
2 4 17 10 42 18 110 42 5
0 5 10 3 21
8
1 7 7 13 31 16 011 41 5
1 5 7 3 17
8
-1 4 17 10 26 21 101 72 5
1 3 7 3 21
8
0 4 15 9 38 21 110 57 5
0 5 7 3 21
8
0 4 33 5 22 21 001 47 5
1 5 4 10 23
8
2 4 17 10 42 18 110 42 5
1 7 7 2 36
8
2 5 16 10 22 21 100 60 5
1 5 9 3 21
8
0 4 15 9 38 21 010 57 5
1 6 10 0 21
8
2 6 9 11 22 14 111 41 5
1 5 10 -1 21
8
0 2 19 11 9 18 011 76 5
0 8 10 0 21
8
-1 4 18 2 39 21 011 42 5
2 5 14 -1 21
8
0 2 19 11 9 14 011 76 5
2 5 12 5 23
8
2 4 17 18 42 18 110 42 5
1 5 12 5 23
8
2 4 17 8 42 18 110 12
no
no
yes
yes
yes
yes
no
no no
no
yes
yes
yes
yes
no
no
 no
yes
no
yes
yes
yes
no
no
 yes
yes
no
yes
yes
yes
no
no
 yes
yes
no
yes
yes
yes
yes
no
 yes
no
no
no
no
yes
yes
no
 yes
no
no
no
no
no
yes
no
 no
no
no
no
no
no
yes
no
 no
no
no
no
no
no
no
no
 no
no
no
no
no
yes
no
no
 no
no
yes
no
no
no
no
no
 no
no
yes
yes
yes
yes
no
yes
 no
no
yes
yes
no
yes
no
no
 no
yes
no
yes
no
no
no
yes
 yes
no
no
no
no
yes
no
no
 yes
yes
yes
yes
yes
yes
no
no
 yes
no
yes
no
no
no
yes
no
 no
no
no
yes
no
yes
no
no
 no
no
no
no
yes
no
no
no
 no
no
no
yes
no
no
no
no
 no
no
no
no
no
yes
yes
no
 no
no
yes
yes
yes
no
no
yes
 no
yes
no
yes
no
no
no
no
 yes
no
yes
no
no
yes
no
no
 yes
no
yes
no
no
yes
yes
no
 no
yes
no
no
no
no
no
no
 yes
no
no
no
yes
yes
no
no
 yes
no
yes
no
no
no
no
no
 no
yes
yes
yes
no
no
no
no
 yes
yes
yes
yes
no
yes
no
no
 no
no
no
yes
no
yes
yes
no
 yes
no
no
yes
yes
yes
yes
no
 no
no
yes
no
no
yes
no
no
 yes
yes
yes
no
no
no
yes
no
 no
no
no
yes
no
no
yes
yes
 no
no
no
yes
no
no
yes
no
 no
no
yes
yes
no
no
yes
no
 yes
yes
no
yes
no
no
no
no
 yes
no
yes
yes
yes
no
no
no
 yes
yes
yes
yes
no
yes
yes
no
 yes
yes
yes
no
yes
no
yes
no
 yes
yes
no
yes
yes
no
no
no
 no
no
yes
yes
no
no
no
no
 yes
yes
yes
yes
yes
no
no
no
 yes
yes
no
yes
no
yes
yes
no
 yes
no
yes
no
yes
yes
no
no
 yes
no
no
yes
yes
no
no
no
 yes
no
yes
no
yes
yes
yes
no
 no
no
no
no
yes
yes
no
no
 yes
yes
yes
no
no
yes
yes
no
 no
no
yes
no
no
no
yes
no
 yes
no
yes
yes
yes
yes
yes
no
 no
yes
no
no
yes
yes
no
no
 yes
yes
no
no
no
yes
yes
no
 yes
no
no
no
no
yes
no
yes
 yes
no
no
no
yes
no
no
no
 yes
yes
no
no
yes
yes
yes
no
 yes
yes
no
no
yes
no
no
no
 yes
yes
yes
no
no
no
no
no
 yes
yes
no
no
no
no
no
no
 yes
yes
no
no
no
no
no
yes
 yes
no
no
no
no
no
no
yes
 no
yes
no
no
yes
no
no
yes
 no
yes
no
no
yes
no
no
no
 yes
no
no
yes
no
no
no
yes
 yes
yes
no
no
no
no
yes
yes
 yes
yes
no
no
no
yes
yes
yes
 yes
yes
yes
no
no
no
no
yes
 yes
yes
no
no
yes
yes
yes
yes
 yes
no
no
no
no
no
no
no
 yes
yes
yes
no
yes
no
no
yes
 yes
yes
yes
no
yes
no
yes
yes
 no
no
no
no
no
no
no
yes
 no
no
yes
yes
yes
no
no
no
 no
yes
yes
no
yes
yes
no
no
 yes
no
no
yes
yes
yes
no
no
 yes
yes
yes
no
yes
yes
no
yes
 no
no
no
no
yes
no
no
yes
 no
yes
yes
yes
no
no
no
yes
 yes
yes
yes
no
yes
yes
no
no
 yes
yes
no
yes
no
no
yes
no
 yes
no
no
no
yes
yes
yes
no
 no
no
no
no
yes
yes
yes
no
 yes
yes
no
yes
no
yes
no
no
 no
no
yes
no
no
yes
yes
no
 no
yes
no
yes
no
yes
no
no
 yes
no
no
no
yes
yes
no
yes
 no
yes
yes
yes
no
yes
no
no
 no
no
no
yes
yes
no
no
no
 no
yes
yes
yes
yes
yes
no
no
 yes
yes
no
no
no
yes
no
no
 yes
no
yes
yes
no
yes
no
no
 no
yes
no
yes
yes
no
no
yes
 yes
no
yes
yes
no
no
no
no
 yes
yes
yes
yes
yes
yes
yes
no
 no
yes
no
yes
yes
no
no
no
 yes
no
no
yes
yes
no
yes
no
 no
no
yes
no
yes
yes
no
no
 yes
yes
yes
no
no
yes
no
no
 yes
no
yes
no
yes
no
no
yes
 no
no
yes
no
no
yes
no
yes
