Problem:
Exhaustive Search

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.

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.

Constraints

n ≤ 20

q ≤ 200

1 ≤ elements in A ≤ 2000

1 ≤ Mi ≤ 2000

Sample Input 1

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

Sample Output 1

no
no
yes
yes
yes
yes
no
no

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].

Solution in C (judge verdict: Accepted)

#include <stdio.h>
#include <stdlib.h>

int *C;
int *A;
int *B;
int Posb, track;

void print(int p){
    int sum = 0;
    for(int i = 0; i <= p; i++){
        
        if(C[i] == 1){
            sum+=A[i];
            if(sum > B[Posb])break;
        }
    }
        if(sum != B[Posb]){
            track=-1;
    }
    if(sum == B[Posb]){
        track = 1;
        return;
    }
}
void find(int l, int p){
    if (l == p){
        if(C[l] == 0)print(p);
        if(track == 1)return;
        if(C[l] == 1) print(p);
        return;
    }
    if(track == 1)return;
    C[l] = 0;
    find(l+1,p);
    if(track == 1)return;
    C[l] = 1;
    find(l+1,p);
    if(track == 1)return;
}
    
int main(){
    
     
    int n;
    scanf("%d",&n);
    A =(int*)malloc(n * sizeof(int));
    for(int a = 0; a < n; a++){
            scanf("%d",&A[a]);
    }

    int m;
    scanf("%d",&m);
    B = (int*)malloc(m * sizeof(int));
    C = (int*)malloc(m * sizeof(int));
    for(int a = 0; a < m; a++){
        scanf("%d",&B[a]);
        C[a] = 0;
    }

    int l = 0;
    for(Posb = 0; Posb < m; Posb++){
    find(l,n);
    
    if(track == 1)printf("yes\n");
    if(track == -1)printf("no\n");
    track = 0;
    }
    free(B);
    free(A);
    return 0;
}