n,a,b,c = list(map(int,input().split()))

L = [int(eval(input())) for i in range(n)]

MP = []

for i in range(4**n):

    i_bit = bin(i)[2:].zfill(2*n)

    co_a = 0

    co_b = 0

    co_c = 0

    p_a = 0

    p_b = 0

    p_c = 0

    for j in range(n):

        if i_bit[-1-2*j:-3-2*j:-1] == '00':

            co_a += L[j]

            p_a += 1

        elif i_bit[-1-2*j:-3-2*j:-1] == '01':

            co_b += L[j]

            p_b += 1

        elif i_bit[-1-2*j:-3-2*j:-1] == '10':

            co_c += L[j]

            p_c += 1

        else:

            continue

    if co_a*co_b*co_c!=0 and p_a<=a and p_b<=b and p_c<=c:

        MP += [10*(p_a+p_b+p_c-3)+abs(a-co_a)+abs(b-co_b)+abs(c-co_c)]

print((min(MP)))
N,A,B,C = list(map(int,input().split()))

L = [int(eval(input())) for _ in range(N)]



minmp = 10**18



for i in range(4**N):

    mp = 0

    a = []

    b = []

    c = []

    d = []

    

    for j in range(N):

        if i>>(2*j) & 1:

            if i>>(2*j+1) & 1:

                a.append(j)

            else:

                b.append(j)

        else:

            if i>>(2*j+1) & 1:

                c.append(j)

            else:

                d.append(j)

                

    if not a or not b or not c:

        continue

        

    mp += (len(a)-1)*10

    mp += abs(A-sum([L[j] for j in a]))

    mp += (len(b)-1)*10

    mp += abs(B-sum([L[j] for j in b]))

    mp += (len(c)-1)*10

    mp += abs(C-sum([L[j] for j in c]))

    minmp = min(mp,minmp)



print(minmp)
n, a, b, c = list(map(int, input().split()))
L = [int(eval(input())) for i in range(n)]
MP = []
for i in range(4**n):
    i_bit = bin(i)[2:].zfill(2 * n)
    co_a = 0
    co_b = 0
    co_c = 0
    p_a = 0
    p_b = 0
    p_c = 0
    for j in range(n):
        if i_bit[-1 - 2 * j : -3 - 2 * j : -1] == "00":
            co_a += L[j]
            p_a += 1
        elif i_bit[-1 - 2 * j : -3 - 2 * j : -1] == "01":
            co_b += L[j]
            p_b += 1
        elif i_bit[-1 - 2 * j : -3 - 2 * j : -1] == "10":
            co_c += L[j]
            p_c += 1
        else:
            continue
    if co_a * co_b * co_c != 0 and p_a <= a and p_b <= b and p_c <= c:
        MP += [
            10 * (p_a + p_b + p_c - 3) + abs(a - co_a) + abs(b - co_b) + abs(c - co_c)
        ]
print((min(MP)))

N, A, B, C = list(map(int, input().split()))
L = [int(eval(input())) for _ in range(N)]
minmp = 10**18
for i in range(4**N):
    mp = 0
    a = []
    b = []
    c = []
    d = []
    for j in range(N):
        if i >> (2 * j) & 1:
            if i >> (2 * j + 1) & 1:
                a.append(j)
            else:
                b.append(j)
        else:
            if i >> (2 * j + 1) & 1:
                c.append(j)
            else:
                d.append(j)
    if not a or not b or not c:
        continue
    mp += (len(a) - 1) * 10
    mp += abs(A - sum([L[j] for j in a]))
    mp += (len(b) - 1) * 10
    mp += abs(B - sum([L[j] for j in b]))
    mp += (len(c) - 1) * 10
    mp += abs(C - sum([L[j] for j in c]))
    minmp = min(mp, minmp)
print(minmp)

-n, a, b, c = list(map(int, input().split())) -L = [int(eval(input())) for i in range(n)] -MP = [] -for i in range(4**n): -    i_bit = bin(i)[2:].zfill(2 * n) -    co_a = 0 -    co_b = 0 -    co_c = 0 -    p_a = 0 -    p_b = 0 -    p_c = 0 -    for j in range(n): -        if i_bit[-1 - 2 * j : -3 - 2 * j : -1] == "00": -            co_a += L[j] -            p_a += 1 -        elif i_bit[-1 - 2 * j : -3 - 2 * j : -1] == "01": -            co_b += L[j] -            p_b += 1 -        elif i_bit[-1 - 2 * j : -3 - 2 * j : -1] == "10": -            co_c += L[j] -            p_c += 1 +N, A, B, C = list(map(int, input().split())) +L = [int(eval(input())) for _ in range(N)] +minmp = 10**18 +for i in range(4**N): +    mp = 0 +    a = [] +    b = [] +    c = [] +    d = [] +    for j in range(N): +        if i >> (2 * j) & 1: +            if i >> (2 * j + 1) & 1: +                a.append(j) +            else: +                b.append(j) -            continue -    if co_a * co_b * co_c != 0 and p_a <= a and p_b <= b and p_c <= c: -        MP += [ -            10 * (p_a + p_b + p_c - 3) + abs(a - co_a) + abs(b - co_b) + abs(c - co_c) -        ] -print((min(MP))) +            if i >> (2 * j + 1) & 1: +                c.append(j) +            else: +                d.append(j) +    if not a or not b or not c: +        continue +    mp += (len(a) - 1) * 10 +    mp += abs(A - sum([L[j] for j in a])) +    mp += (len(b) - 1) * 10 +    mp += abs(B - sum([L[j] for j in b])) +    mp += (len(c) - 1) * 10 +    mp += abs(C - sum([L[j] for j in c])) +    minmp = min(mp, minmp) +print(minmp)