The integers a1, a2, ...., an are given. Choose some of them and determine if the sum can be just k.
#input
n = int(input())
a = list(map(int, input().split()))
k = int(input())
#Variables for judgment
cnt = 0
#Full search
for i in range(1<<len(a)):
    l = []
    for j in range(len(a)):
        if (i>>j & 1) == 1:
            l.append(a[j])
    if sum(l) == k:
        cnt += 1
print('Yes' if cnt>=1 else 'No')
        Recommended Posts