from itertools import product



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

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



ans = 10 ** 10

for bit in product([0, 1, 2, 3], repeat=n):

    tmp = [0] * 4

    mp = 0

    for i, j in enumerate(bit):

        if j != 3 and tmp[j] != 0:

            mp += 10

        tmp[j] += l[i]

    if any([i == 0 for i in tmp[:3]]):

        continue

    mp += abs(a - tmp[0]) + abs(b - tmp[1]) + abs(c - tmp[2])

    ans = min(ans, mp)

print(ans)

# dfs版

def dfs(d, A, B, C, f):

    global ans

    if d == n:

        if not 0 in [A, B, C]:

            ans = min(ans, abs(a - A) + abs(b - B) + abs(c - C) + f - 30)

        return

    dfs(d + 1, A, B, C, f)

    dfs(d + 1, A + l[d], B, C, f + 10)

    dfs(d + 1, A, B + l[d], C, f + 10)

    dfs(d + 1, A, B, C + l[d], f + 10)





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

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

ans = 10 ** 10

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

print(ans)

from itertools import product

n, a, b, c = list(map(int, input().split()))
l = [int(eval(input())) for _ in range(n)]
ans = 10**10
for bit in product([0, 1, 2, 3], repeat=n):
    tmp = [0] * 4
    mp = 0
    for i, j in enumerate(bit):
        if j != 3 and tmp[j] != 0:
            mp += 10
        tmp[j] += l[i]
    if any([i == 0 for i in tmp[:3]]):
        continue
    mp += abs(a - tmp[0]) + abs(b - tmp[1]) + abs(c - tmp[2])
    ans = min(ans, mp)
print(ans)

# dfs版
def dfs(d, A, B, C, f):
    global ans
    if d == n:
        if not 0 in [A, B, C]:
            ans = min(ans, abs(a - A) + abs(b - B) + abs(c - C) + f - 30)
        return
    dfs(d + 1, A, B, C, f)
    dfs(d + 1, A + l[d], B, C, f + 10)
    dfs(d + 1, A, B + l[d], C, f + 10)
    dfs(d + 1, A, B, C + l[d], f + 10)


n, a, b, c = list(map(int, input().split()))
l = [int(eval(input())) for _ in range(n)]
ans = 10**10
dfs(0, 0, 0, 0, 0)
print(ans)

-from itertools import product +# dfs版 +def dfs(d, A, B, C, f): +    global ans +    if d == n: +        if not 0 in [A, B, C]: +            ans = min(ans, abs(a - A) + abs(b - B) + abs(c - C) + f - 30) +        return +    dfs(d + 1, A, B, C, f) +    dfs(d + 1, A + l[d], B, C, f + 10) +    dfs(d + 1, A, B + l[d], C, f + 10) +    dfs(d + 1, A, B, C + l[d], f + 10) + -for bit in product([0, 1, 2, 3], repeat=n): -    tmp = [0] * 4 -    mp = 0 -    for i, j in enumerate(bit): -        if j != 3 and tmp[j] != 0: -            mp += 10 -        tmp[j] += l[i] -    if any([i == 0 for i in tmp[:3]]): -        continue -    mp += abs(a - tmp[0]) + abs(b - tmp[1]) + abs(c - tmp[2]) -    ans = min(ans, mp) +dfs(0, 0, 0, 0, 0)