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

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



import itertools

m = 4

n = N

bit_list = list(itertools.product([i for i in range(m)], repeat=n))



res = 10 ** 18

for b in bit_list:

    tmp1 = 0

    tmp2 = 0

    tmp3 = 0

    check1 = False

    check2 = False

    check3 = False

    cost = 0

    for i in range(n):

        if b[i] == 1:

            tmp1 += L[i]

            if check1:

                cost += 10

            check1 = True       

            

        if b[i] == 2:

            tmp2 += L[i]

            if check2:

                cost += 10

            check2 = True

            

        if b[i] == 3:

            tmp3 += L[i]

            if check3:

                cost += 10

            check3 = True

    if min(tmp1, tmp2, tmp3) != 0:

        res = min(res, abs(tmp1 - A)+abs(tmp2 - B)+abs(tmp3 - C)+cost)

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

L = []

for i in range(N):

    L.append(int(eval(input())))

    

import itertools

m = 4

bit_list = list(itertools.product([i for i in range(m)], repeat=N))

ans = 10 ** 18

for bit in bit_list:

    retA = 0

    retB = 0

    retC = 0

    checkA = False

    checkB = False

    checkC = False

    cost = 0

    for i,j in enumerate(bit):

        if j == 1:

            retA += L[i]

            if checkA:

                cost += 10

            checkA = True

        if j == 2:

            retB += L[i]

            if checkB:

                cost += 10

            checkB = True

        if j == 3:

            retC += L[i]

            if checkC:

                cost += 10

            checkC = True

    if min(retA,retB,retC) != 0:

        ans = min(ans, abs(A-retA)+abs(B-retB)+abs(C-retC)+cost)

print(ans) 
N, A, B, C = list(map(int, input().split()))
L = [int(eval(input())) for _ in range(N)]
import itertools

m = 4
n = N
bit_list = list(itertools.product([i for i in range(m)], repeat=n))
res = 10**18
for b in bit_list:
    tmp1 = 0
    tmp2 = 0
    tmp3 = 0
    check1 = False
    check2 = False
    check3 = False
    cost = 0
    for i in range(n):
        if b[i] == 1:
            tmp1 += L[i]
            if check1:
                cost += 10
            check1 = True
        if b[i] == 2:
            tmp2 += L[i]
            if check2:
                cost += 10
            check2 = True
        if b[i] == 3:
            tmp3 += L[i]
            if check3:
                cost += 10
            check3 = True
    if min(tmp1, tmp2, tmp3) != 0:
        res = min(res, abs(tmp1 - A) + abs(tmp2 - B) + abs(tmp3 - C) + cost)
print(res)

N, A, B, C = list(map(int, input().split()))
L = []
for i in range(N):
    L.append(int(eval(input())))
import itertools

m = 4
bit_list = list(itertools.product([i for i in range(m)], repeat=N))
ans = 10**18
for bit in bit_list:
    retA = 0
    retB = 0
    retC = 0
    checkA = False
    checkB = False
    checkC = False
    cost = 0
    for i, j in enumerate(bit):
        if j == 1:
            retA += L[i]
            if checkA:
                cost += 10
            checkA = True
        if j == 2:
            retB += L[i]
            if checkB:
                cost += 10
            checkB = True
        if j == 3:
            retC += L[i]
            if checkC:
                cost += 10
            checkC = True
    if min(retA, retB, retC) != 0:
        ans = min(ans, abs(A - retA) + abs(B - retB) + abs(C - retC) + cost)
print(ans)

-L = [int(eval(input())) for _ in range(N)] +L = [] +for i in range(N): +    L.append(int(eval(input()))) -n = N -bit_list = list(itertools.product([i for i in range(m)], repeat=n)) -res = 10**18 -for b in bit_list: -    tmp1 = 0 -    tmp2 = 0 -    tmp3 = 0 -    check1 = False -    check2 = False -    check3 = False +bit_list = list(itertools.product([i for i in range(m)], repeat=N)) +ans = 10**18 +for bit in bit_list: +    retA = 0 +    retB = 0 +    retC = 0 +    checkA = False +    checkB = False +    checkC = False -    for i in range(n): -        if b[i] == 1: -            tmp1 += L[i] -            if check1: +    for i, j in enumerate(bit): +        if j == 1: +            retA += L[i] +            if checkA: -            check1 = True -        if b[i] == 2: -            tmp2 += L[i] -            if check2: +            checkA = True +        if j == 2: +            retB += L[i] +            if checkB: -            check2 = True -        if b[i] == 3: -            tmp3 += L[i] -            if check3: +            checkB = True +        if j == 3: +            retC += L[i] +            if checkC: -            check3 = True -    if min(tmp1, tmp2, tmp3) != 0: -        res = min(res, abs(tmp1 - A) + abs(tmp2 - B) + abs(tmp3 - C) + cost) -print(res) +            checkC = True +    if min(retA, retB, retC) != 0: +        ans = min(ans, abs(A - retA) + abs(B - retB) + abs(C - retC) + cost) +print(ans)