Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
????????????
?????? n ?????°??? A ??¨??´??° m ???????????????A ???????´?????????????????????????????´?????¶????????????????
m ???????????????????????????????????????????????°????????????????????????????????????
AA ??????????´???????????????????????????¨?????§????????????

??°??? A ??????????????????????????§???????????¨?????? q ?????? mi ????????????????????§???
???????????????????????? "yes" ????????? "no" ??¨???????????????????????????

n ??? 20 ; q ??? 200 ; 1 ??? A???????´? ??? 2000 ; 1 ??? Mi ??? 2000

"""

def kenzan(m, n, A):
    l = 2 ** n
    for i in range(l):
        mask = 1
        c = 0
        for j in range(n):
            b = i & mask
            if b != 0:
                x = c + A[j]
#                print("{0:2}/{1:2} {6:08b} m[{2:4}] c+Aj[{3:4}] c[{4:4}] Aj[{5:4}]".format(i, mask, m, x, c, A[j], b))
                if x == m:
                    return 0
                elif x > m:
                    break
                else:
                    c = x
            mask <<= 1
    return -1
 
def main():
    """ ????????? """
    n = int(input())
    A = list(map(int,input().split()))
    q = int(input())
    M = list(map(int,input().split()))

    for i in range(q):
        if kenzan(M[i], n, A) == 0:
            print("yes")
        else:
            print("no")


if __name__ == '__main__':
    main()

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
????????????
?????? n ?????°??? A ??¨??´??° m ???????????????A ???????´?????????????????????????????´?????¶????????????????
m ???????????????????????????????????????????????°????????????????????????????????????
AA ??????????´???????????????????????????¨?????§????????????

??°??? A ??????????????????????????§???????????¨?????? q ?????? mi ????????????????????§???
???????????????????????? "yes" ????????? "no" ??¨???????????????????????????

n ??? 20 ; q ??? 200 ; 1 ??? A???????´? ??? 2000 ; 1 ??? Mi ??? 2000

"""

def main():
    """ ????????? """
    n = int(input())
    A = sorted(map(int,input().split()))
    q = int(input())
    M = list(map(int,input().split()))
    g = 0

    tA = []
    l = 2 ** n
    for i in range(1,l):
        c = 0
        bi = "{0:0{width}b}".format(i,width=n)
        bi = bi[::-1]
        for j in range(n):
            if bi[j] == "1":
                c += A[j]
        tA.append(c)
#    tA.sort()

    for mi in M:
        if mi in tA:
            print("yes")
        else:
            print("no")

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
????????????
?????? n ?????°??? A ??¨??´??° m ???????????????A ???????´?????????????????????????????´?????¶????????????????
m ???????????????????????????????????????????????°????????????????????????????????????
AA ??????????´???????????????????????????¨?????§????????????

??°??? A ??????????????????????????§???????????¨?????? q ?????? mi ????????????????????§???
???????????????????????? "yes" ????????? "no" ??¨???????????????????????????

n ??? 20 ; q ??? 200 ; 1 ??? A???????´? ??? 2000 ; 1 ??? Mi ??? 2000

"""

def kenzan(m, n, A):

    # ?????????????????§????????°???????????£????????????
    nA = []
    max = 0
    min = 2000
    total = 0
    for i in range(n):
        if A[i] == m:
            return 0
        elif A[i] < m:
            nA.append(A[i])
        if max < A[i]:
            max = A[i]
        if min > A[i]:
            min = A[i]
        total += A[i]

    n =len(nA)

    if m > total:
        return -1
    elif m < min:
        return -1

    l = 2 ** n
    for i in range(l):
        mask = 1
        c = 0
        for j in range(n):
            b = i & mask
            if b != 0:
                x = c + nA[j]
#                print("{0:2}/{1:2} {6:08b} m[{2:4}] c+Aj[{3:4}] c[{4:4}] Aj[{5:4}]".format(i, mask, m, x, c, nA[j], b))
                if x == m:
                    return 0
                elif x > m:
                    break
                else:
                    c = x
            mask <<= 1
    return -1
 
def main():
    """ ????????? """
    n = int(input())
    A = list(map(int,input().split()))
    q = int(input())
    M = list(map(int,input().split()))

    for i in range(q):
        if kenzan(M[i], n, A) == 0:
            print("yes")
        else:
            print("no")


if __name__ == '__main__':
    main()

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
????????????
?????? n ?????°??? A ??¨??´??° m ???????????????A ???????´?????????????????????????????´?????¶????????????????
m ???????????????????????????????????????????????°????????????????????????????????????
AA ??????????´???????????????????????????¨?????§????????????

??°??? A ??????????????????????????§???????????¨?????? q ?????? mi ????????????????????§???
???????????????????????? "yes" ????????? "no" ??¨???????????????????????????

n ??? 20 ; q ??? 200 ; 1 ??? A???????´? ??? 2000 ; 1 ??? Mi ??? 2000

"""

def main():
    """ ????????? """
    n = int(input())
    A = sorted(map(int,input().split()))
    q = int(input())
    M = list(map(int,input().split()))
    g = 0

    tA = []
    l = 2 ** n
    for i in range(1,l):
        c = 0
        bi = "{0:0{width}b}".format(i,width=n)
        bi = bi[::-1]
        for j in range(n):
            if bi[j] == "1":
                c += A[j]
        tA.append(c)
#    tA.sort()

    for mi in M:
        if mi in tA:
            print("yes")
        else:
            print("no")

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
????????????
?????? n ?????°??? A ??¨??´??° m ???????????????A ???????´?????????????????????????????´?????¶????????????????
m ???????????????????????????????????????????????°????????????????????????????????????
AA ??????????´???????????????????????????¨?????§????????????

??°??? A ??????????????????????????§???????????¨?????? q ?????? mi ????????????????????§???
???????????????????????? "yes" ????????? "no" ??¨???????????????????????????

n ??? 20 ; q ??? 200 ; 1 ??? A???????´? ??? 2000 ; 1 ??? Mi ??? 2000

"""
def kenzan(m, n, A):

    if m < A[0]:
        return -1

    # ?????????????????§????????°???????????£????????????
    total = 0
    nA = []
    for i in range(n):
        if A[i] == m:
            return 0
#        print("{} m:{} x:{} total:{}".format(nA,m,A[i], total))
        if A[i] > m:
            break
        nA.append(A[i])
        total += A[i]

    if m > total:
        return -1

    n =len(nA)
    l = 2 ** n
    for i in range(1,l):
        c = 0
        bi = "{0:0<{width}b}".format(i,width=n)
        bi = bi[::-1]
#        print("{0:2}[{1}] m[{2:4}] {3}".format(i, bi,m, n))
        for j in range(n):
#            print("\tj:{} bi:{} Aj[{:4}]".format(j, bi[j], A[j]))
            if bi[j] == "1":
                x = c + nA[j]
#                print("\tm[{:4}] c+Aj[{:4}] c[{:4}] j:{} Aj[{:4}]".format(m, x, c, j, A[j]))
                if x == m:
                    return 0
                elif x > m:
#                    print("BAD")
                    break
                else:
                    c = x
    return -1
 
def main():
    """ ????????? """
    n = int(input())
    A = sorted(map(int,input().split()))
    q = int(input())
    M = list(map(int,input().split()))

    for i in range(q):

        if kenzan(M[i], n, A) == 0:
            print("yes")
        else:
            print("no")


if __name__ == '__main__':
    main()

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
????????????
?????? n ?????°??? A ??¨??´??° m ???????????????A ???????´?????????????????????????????´?????¶????????????????
m ???????????????????????????????????????????????°????????????????????????????????????
AA ??????????´???????????????????????????¨?????§????????????

??°??? A ??????????????????????????§???????????¨?????? q ?????? mi ????????????????????§???
???????????????????????? "yes" ????????? "no" ??¨???????????????????????????

n ??? 20 ; q ??? 200 ; 1 ??? A???????´? ??? 2000 ; 1 ??? Mi ??? 2000

"""

def main():
    """ ????????? """
    n = int(input())
    A = sorted(map(int,input().split()))
    q = int(input())
    M = list(map(int,input().split()))
    g = 0

    tA = []
    l = 2 ** n
    for i in range(1,l):
        c = 0
        bi = "{0:0{width}b}".format(i,width=n)
        bi = bi[::-1]
        for j in range(n):
            if bi[j] == "1":
                c += A[j]
        tA.append(c)
#    tA.sort()

    for mi in M:
        if mi in tA:
            print("yes")
        else:
            print("no")

if __name__ == '__main__':
    main()