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

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

targets = [a, b, c]



ans = 10**9

from itertools import product

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

    if len(set(comb)) in [1, 2]:

        continue

    # a, b, c

    ls = [[], [], []]

    for i, c in enumerate(comb):

        if c == 3:

            continue

        ls[c].append(L[i])



    mps = 0

    for idx, ll in enumerate(ls):

        if len(ll) == 0:

            break

        tmp = (len(ll)-1)*10

        mps += tmp

        mps += abs(targets[idx] - sum(ll))

    else:

        ans = min(ans, mps)

    

print(ans)

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

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

INF = 10**9



def rec(cur, a, b, c):

    if cur == n:

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

    ret0 = rec(cur+1, a, b, c)

    ret1 = rec(cur+1, a+L[cur], b, c) + 10

    ret2 = rec(cur+1, a, b+L[cur], c) + 10

    ret3 = rec(cur+1, a, b, c+L[cur]) + 10

    return min(ret0, ret1, ret2, ret3)



print((rec(0, 0, 0, 0)))

n, a, b, c = list(map(int, input().split()))
L = [int(eval(input())) for _ in range(n)]
targets = [a, b, c]
ans = 10**9
from itertools import product

for comb in product([0, 1, 2, 3], repeat=n):
    if len(set(comb)) in [1, 2]:
        continue
    # a, b, c
    ls = [[], [], []]
    for i, c in enumerate(comb):
        if c == 3:
            continue
        ls[c].append(L[i])
    mps = 0
    for idx, ll in enumerate(ls):
        if len(ll) == 0:
            break
        tmp = (len(ll) - 1) * 10
        mps += tmp
        mps += abs(targets[idx] - sum(ll))
    else:
        ans = min(ans, mps)
print(ans)

n, A, B, C = list(map(int, input().split()))
L = [int(eval(input())) for _ in range(n)]
INF = 10**9


def rec(cur, a, b, c):
    if cur == n:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
    ret0 = rec(cur + 1, a, b, c)
    ret1 = rec(cur + 1, a + L[cur], b, c) + 10
    ret2 = rec(cur + 1, a, b + L[cur], c) + 10
    ret3 = rec(cur + 1, a, b, c + L[cur]) + 10
    return min(ret0, ret1, ret2, ret3)


print((rec(0, 0, 0, 0)))

-n, a, b, c = list(map(int, input().split())) +n, A, B, C = list(map(int, input().split())) -targets = [a, b, c] -ans = 10**9 -from itertools import product +INF = 10**9 -for comb in product([0, 1, 2, 3], repeat=n): -    if len(set(comb)) in [1, 2]: -        continue -    # a, b, c -    ls = [[], [], []] -    for i, c in enumerate(comb): -        if c == 3: -            continue -        ls[c].append(L[i]) -    mps = 0 -    for idx, ll in enumerate(ls): -        if len(ll) == 0: -            break -        tmp = (len(ll) - 1) * 10 -        mps += tmp -        mps += abs(targets[idx] - sum(ll)) -    else: -        ans = min(ans, mps) -print(ans) + +def rec(cur, a, b, c): +    if cur == n: +        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF +    ret0 = rec(cur + 1, a, b, c) +    ret1 = rec(cur + 1, a + L[cur], b, c) + 10 +    ret2 = rec(cur + 1, a, b + L[cur], c) + 10 +    ret3 = rec(cur + 1, a, b, c + L[cur]) + 10 +    return min(ret0, ret1, ret2, ret3) + + +print((rec(0, 0, 0, 0)))