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:

        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, plus):

    global ans



    if i == n:

        if a and b and c:

            mp = abs(a - A) + abs(b - B) + abs(c - C) + (plus - 3) * 10

            ans = min(ans, mp)



    else:

        dfs(i + 1, a, b, c, plus)

        dfs(i + 1, a + l[i], b, c, plus + 1)

        dfs(i + 1, a, b + l[i], c, plus + 1)

        dfs(i + 1, a, b, c + l[i], plus + 1)





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

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



ans = float("inf")



dfs(0, 0, 0, 0, 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:
        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, plus):
    global ans
    if i == n:
        if a and b and c:
            mp = abs(a - A) + abs(b - B) + abs(c - C) + (plus - 3) * 10
            ans = min(ans, mp)
    else:
        dfs(i + 1, a, b, c, plus)
        dfs(i + 1, a + l[i], b, c, plus + 1)
        dfs(i + 1, a, b + l[i], c, plus + 1)
        dfs(i + 1, a, b, c + l[i], plus + 1)


n, A, B, C = list(map(int, input().split()))
l = [int(eval(input())) for i in range(n)]
ans = float("inf")
dfs(0, 0, 0, 0, 0)
print(ans)

-def dfs(i, A, B, C): +def dfs(i, a, b, c, plus): -        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, -            ) +        if a and b and c: +            mp = abs(a - A) + abs(b - B) + abs(c - C) + (plus - 3) * 10 +            ans = min(ans, mp) -        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]]) +        dfs(i + 1, a, b, c, plus) +        dfs(i + 1, a + l[i], b, c, plus + 1) +        dfs(i + 1, a, b + l[i], c, plus + 1) +        dfs(i + 1, a, b, c + l[i], plus + 1) -n, a, b, c = list(map(int, input().split())) -L = [int(eval(input())) for i in range(n)] +n, A, B, C = list(map(int, input().split())) +l = [int(eval(input())) for i in range(n)] -dfs(0, [], [], []) +dfs(0, 0, 0, 0, 0)