def dfs(i, A, B, C):

    global ans

    if i == n:

        if A and B and C:

            s = 0

            ABC = [A, B, C]

            for i in range(3):

                s += (len(ABC[i]) - 1) * 10 + abs(sum(ABC[i]) - abc[i])

            ans = min(ans, s)

    else:

        dfs(i + 1, A + [l[i]], B, C)

        dfs(i + 1, A, B + [l[i]], C)

        dfs(i + 1, A, B, C + [l[i]])

        dfs(i + 1, A, B, C)



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

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

abc = [a, b, c]

ans = float("inf")

dfs(0, [], [], [])

print(ans)
def dfs(i, A, B, C):

    global ans

    if i == n:

        if A and B and C:

            ans = min(ans, abs(a - sum(A)) + abs(b - sum(B)) + abs(c - sum(C)) + (len(A) + len(B) + len(C) - 3) * 10)

    else:

        # a の肉焼き器に乗せるか、 b の肉焼き器に乗せるか

        dfs(i + 1, A, B, C)

        dfs(i + 1, A + [L[i]], B, C)

        dfs(i + 1, A, B + [L[i]], C)

        dfs(i + 1, A, B, C + [L[i]])



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

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

ans = float("inf")

dfs(0, [], [], [])

print(ans)
def dfs(i, A, B, C):
    global ans
    if i == n:
        if A and B and C:
            s = 0
            ABC = [A, B, C]
            for i in range(3):
                s += (len(ABC[i]) - 1) * 10 + abs(sum(ABC[i]) - abc[i])
            ans = min(ans, s)
    else:
        dfs(i + 1, A + [l[i]], B, C)
        dfs(i + 1, A, B + [l[i]], C)
        dfs(i + 1, A, B, C + [l[i]])
        dfs(i + 1, A, B, C)


n, a, b, c = list(map(int, input().split()))
l = [int(eval(input())) for i in range(n)]
abc = [a, b, c]
ans = float("inf")
dfs(0, [], [], [])
print(ans)

def dfs(i, A, B, C):
    global ans
    if i == n:
        if A and B and C:
            ans = min(
                ans,
                abs(a - sum(A))
                + abs(b - sum(B))
                + abs(c - sum(C))
                + (len(A) + len(B) + len(C) - 3) * 10,
            )
    else:
        # a の肉焼き器に乗せるか、 b の肉焼き器に乗せるか
        dfs(i + 1, A, B, C)
        dfs(i + 1, A + [L[i]], B, C)
        dfs(i + 1, A, B + [L[i]], C)
        dfs(i + 1, A, B, C + [L[i]])


n, a, b, c = list(map(int, input().split()))
L = [int(eval(input())) for i in range(n)]
ans = float("inf")
dfs(0, [], [], [])
print(ans)

-            s = 0 -            ABC = [A, B, C] -            for i in range(3): -                s += (len(ABC[i]) - 1) * 10 + abs(sum(ABC[i]) - abc[i]) -            ans = min(ans, s) +            ans = min( +                ans, +                abs(a - sum(A)) +                + abs(b - sum(B)) +                + abs(c - sum(C)) +                + (len(A) + len(B) + len(C) - 3) * 10, +            ) -        dfs(i + 1, A + [l[i]], B, C) -        dfs(i + 1, A, B + [l[i]], C) -        dfs(i + 1, A, B, C + [l[i]]) +        # a の肉焼き器に乗せるか、 b の肉焼き器に乗せるか +        dfs(i + 1, A + [L[i]], B, C) +        dfs(i + 1, A, B + [L[i]], C) +        dfs(i + 1, A, B, C + [L[i]]) -l = [int(eval(input())) for i in range(n)] -abc = [a, b, c] +L = [int(eval(input())) for i in range(n)]