from collections import deque



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

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

minMP = 10**5



p = deque()

p.append([-1] * len(L))

while p:

    stats = p.pop()

    stats = list(stats)

    a, b, c = 0, 0, 0

    MP = 0

    cntA = 0; cntB = 0; cntC = 0

    for i in range(N):

        if stats[i] == 1:

            a += L[i]

            cntA += 1

        elif stats[i] == 2:

            b += L[i]

            cntB += 1

        elif stats[i] == 3:

            c += L[i]

            cntC += 1



    if cntA >= 1 and cntB >= 1 and cntC >= 1:

        MP += abs(A - a) + abs(B - b) + abs(C - c) + 10 * (cntA+cntB+cntC-3)

        minMP = min(minMP, MP)



    if not -1 in stats:

        continue

    j = stats.index(-1)

    for k in range(4):

        stats[j] = k

        newStats = tuple(stats)

        p.append(newStats)



print(minMP)

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

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

INF = float('inf')



def dfs(cursor=0, a=0, b=0, c=0):

    if cursor == N:

        return abs(a-A) + abs(b-B) + abs(c-C) - 30 if a*b*c > 0 else INF



    no_compound = dfs(cursor+1, a, b, c)

    A_compound = dfs(cursor+1, a+L[cursor], b, c) + 10

    B_compound = dfs(cursor+1, a, b+L[cursor], c) + 10

    C_compound = dfs(cursor+1, a, b, c+L[cursor]) + 10

    return min(no_compound, A_compound, B_compound, C_compound)



print((dfs()))

from collections import deque

N, A, B, C = list(map(int, input().split()))
L = [int(eval(input())) for _ in range(N)]
minMP = 10**5
p = deque()
p.append([-1] * len(L))
while p:
    stats = p.pop()
    stats = list(stats)
    a, b, c = 0, 0, 0
    MP = 0
    cntA = 0
    cntB = 0
    cntC = 0
    for i in range(N):
        if stats[i] == 1:
            a += L[i]
            cntA += 1
        elif stats[i] == 2:
            b += L[i]
            cntB += 1
        elif stats[i] == 3:
            c += L[i]
            cntC += 1
    if cntA >= 1 and cntB >= 1 and cntC >= 1:
        MP += abs(A - a) + abs(B - b) + abs(C - c) + 10 * (cntA + cntB + cntC - 3)
        minMP = min(minMP, MP)
    if not -1 in stats:
        continue
    j = stats.index(-1)
    for k in range(4):
        stats[j] = k
        newStats = tuple(stats)
        p.append(newStats)
print(minMP)

N, A, B, C = list(map(int, input().split()))
L = [int(eval(input())) for _ in range(N)]
INF = float("inf")


def dfs(cursor=0, a=0, b=0, c=0):
    if cursor == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if a * b * c > 0 else INF
    no_compound = dfs(cursor + 1, a, b, c)
    A_compound = dfs(cursor + 1, a + L[cursor], b, c) + 10
    B_compound = dfs(cursor + 1, a, b + L[cursor], c) + 10
    C_compound = dfs(cursor + 1, a, b, c + L[cursor]) + 10
    return min(no_compound, A_compound, B_compound, C_compound)


print((dfs()))

-from collections import deque - -minMP = 10**5 -p = deque() -p.append([-1] * len(L)) -while p: -    stats = p.pop() -    stats = list(stats) -    a, b, c = 0, 0, 0 -    MP = 0 -    cntA = 0 -    cntB = 0 -    cntC = 0 -    for i in range(N): -        if stats[i] == 1: -            a += L[i] -            cntA += 1 -        elif stats[i] == 2: -            b += L[i] -            cntB += 1 -        elif stats[i] == 3: -            c += L[i] -            cntC += 1 -    if cntA >= 1 and cntB >= 1 and cntC >= 1: -        MP += abs(A - a) + abs(B - b) + abs(C - c) + 10 * (cntA + cntB + cntC - 3) -        minMP = min(minMP, MP) -    if not -1 in stats: -        continue -    j = stats.index(-1) -    for k in range(4): -        stats[j] = k -        newStats = tuple(stats) -        p.append(newStats) -print(minMP) +INF = float("inf") + + +def dfs(cursor=0, a=0, b=0, c=0): +    if cursor == N: +        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if a * b * c > 0 else INF +    no_compound = dfs(cursor + 1, a, b, c) +    A_compound = dfs(cursor + 1, a + L[cursor], b, c) + 10 +    B_compound = dfs(cursor + 1, a, b + L[cursor], c) + 10 +    C_compound = dfs(cursor + 1, a, b, c + L[cursor]) + 10 +    return min(no_compound, A_compound, B_compound, C_compound) + + +print((dfs()))