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 Ruby (judge verdict: Time Limit Exceeded)

#!/usr/bin/ruby
# -*- coding: utf-8 -*-
=begin
ALDS1_5-A
Recursion / Divide and Conquer - Exhaustive Search
????????¶??? : 5 sec, ?????¢?????¶??? : 65536 KB
=end

class Main
  def sum(f)
    f.inject(0){|acc,x| acc + x}
  end

  def issum(v, f)
    return false if v > sum(f)
    g = f.select{|x| x <= v}
    h = []
    1.upto(g.length) {|i|
      h = g.combination(i).to_a.map{|w| sum(w)}.select{|x| x == v}
      return true if h.length>0
    }
    return false
  end

=begin
    1.upto(g.length) {|i|
      h = h + g.combination(i).to_a

    }
    l=h.map{|w| sum(w)}
    m = l.select{|x| x == v}
    if m.length>0 then
      return true
    else
      return false
    end
=end

  def initialize
    #fh=open("/home/muz/Downloads/ALDS1_5_A_in1.txt")
    #fh=open("/home/muz/Downloads/ALDS1_5_A_in10.txt")
    fh=STDIN
    n=fh.gets.chomp.to_i
    f=fh.gets.chomp.split.map{|x| x.to_i}
    q=fh.gets.chomp.to_i
    g=fh.gets.chomp.split.map{|x| x.to_i}
    fh.close
    g.each{|y|
      puts issum(y,f) ? "yes" : "no"
    }
  end

end

if $0==__FILE__ then
  Main.new()
end