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

l = [int(input()) for i in range(N)]

def return_4(x, k):

    four_hairetu = [0 for i in range(k)]

    for i in range(k):

        four_hairetu[i] = x%4

        x = x//4

    return four_hairetu

min_mp = 1000000

for i in range(4**N):

    ABC = [0,0,0,0] #[not,A,B,C] = [0,1,2,3]

    zABC = return_4(i,N)

    if zABC.count(1)==0 or zABC.count(2)==0 or zABC.count(3)==0:

        continue

    else:

        kouho_mp = (zABC.count(1)-1)*10 + \

                   (zABC.count(2)-1)*10 + \

                   (zABC.count(3)-1)*10

        for j in range(N):

            ABC[zABC[j]] += l[j]

        kouho_mp += abs(ABC[1]-A) + abs(ABC[2]-B) + abs(ABC[3]-C)

        min_mp = min(min_mp, kouho_mp)

print(min_mp)

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

l = [int(eval(input())) for i in range(N)]

def dfs(k,a,b,c):

    global N,A,B,C,l

    if k == N:

        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else 1000000

    det0 = dfs(k+1, a+l[k], b, c)+10

    det1 = dfs(k+1, a, b+l[k], c)+10

    det2 = dfs(k+1, a, b, c+l[k])+10

    det3 = dfs(k+1, a, b, c)

    return min(det0, det1, det2, det3)

print((dfs(0,0,0,0)))
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]


def return_4(x, k):
    four_hairetu = [0 for i in range(k)]
    for i in range(k):
        four_hairetu[i] = x % 4
        x = x // 4
    return four_hairetu


min_mp = 1000000
for i in range(4**N):
    ABC = [0, 0, 0, 0]  # [not,A,B,C] = [0,1,2,3]
    zABC = return_4(i, N)
    if zABC.count(1) == 0 or zABC.count(2) == 0 or zABC.count(3) == 0:
        continue
    else:
        kouho_mp = (
            (zABC.count(1) - 1) * 10
            + (zABC.count(2) - 1) * 10
            + (zABC.count(3) - 1) * 10
        )
        for j in range(N):
            ABC[zABC[j]] += l[j]
        kouho_mp += abs(ABC[1] - A) + abs(ABC[2] - B) + abs(ABC[3] - C)
        min_mp = min(min_mp, kouho_mp)
print(min_mp)

N, A, B, C = list(map(int, input().split()))
l = [int(eval(input())) for i in range(N)]


def dfs(k, a, b, c):
    global N, A, B, C, l
    if k == N:
        return (
            abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else 1000000
        )
    det0 = dfs(k + 1, a + l[k], b, c) + 10
    det1 = dfs(k + 1, a, b + l[k], c) + 10
    det2 = dfs(k + 1, a, b, c + l[k]) + 10
    det3 = dfs(k + 1, a, b, c)
    return min(det0, det1, det2, det3)


print((dfs(0, 0, 0, 0)))

-N, A, B, C = map(int, input().split()) -l = [int(input()) for i in range(N)] +N, A, B, C = list(map(int, input().split())) +l = [int(eval(input())) for i in range(N)] -def return_4(x, k): -    four_hairetu = [0 for i in range(k)] -    for i in range(k): -        four_hairetu[i] = x % 4 -        x = x // 4 -    return four_hairetu +def dfs(k, a, b, c): +    global N, A, B, C, l +    if k == N: +        return ( +            abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else 1000000 +        ) +    det0 = dfs(k + 1, a + l[k], b, c) + 10 +    det1 = dfs(k + 1, a, b + l[k], c) + 10 +    det2 = dfs(k + 1, a, b, c + l[k]) + 10 +    det3 = dfs(k + 1, a, b, c) +    return min(det0, det1, det2, det3) -min_mp = 1000000 -for i in range(4**N): -    ABC = [0, 0, 0, 0]  # [not,A,B,C] = [0,1,2,3] -    zABC = return_4(i, N) -    if zABC.count(1) == 0 or zABC.count(2) == 0 or zABC.count(3) == 0: -        continue -    else: -        kouho_mp = ( -            (zABC.count(1) - 1) * 10 -            + (zABC.count(2) - 1) * 10 -            + (zABC.count(3) - 1) * 10 -        ) -        for j in range(N): -            ABC[zABC[j]] += l[j] -        kouho_mp += abs(ABC[1] - A) + abs(ABC[2] - B) + abs(ABC[3] - C) -        min_mp = min(min_mp, kouho_mp) -print(min_mp) +print((dfs(0, 0, 0, 0)))