# 4進数



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

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

INF = float('inf')



ans = INF

for ptn in range(1 << (2 * N)):

    abc = [0 for _ in range(4)]



    v = [None for _ in range(N)]

    # lの各idxをどの竹用に割り当てるか, ABC無 = 0123



    cnt = 0

    for j in range(N):

        v[j] = (ptn >> (2 * j)) & 3

        abc[v[j]] += l[j]

        if 0 <= v[j] < 3:

            cnt += 1



    if 0 in abc[:3]: continue

    ans = min(ans, sum(abs(x - t) for x, t in zip(abc[:3], [A, B, C])) + (cnt - 3) * 10)

print(ans)

# dfs



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

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

INF = float('inf')





def calc(mask):

    abc = [0 for _ in range(4)]

    cnt = 0

    for j in range(N):

        idx = (mask >> (2 * j)) & 3

        abc[idx] += l[j]

        if 0 <= idx < 3:

            cnt += 1

    if 0 in abc[:3]:

        return INF

    return sum(abs(x - t) for x, t in zip(abc, [A, B, C])) + (cnt - 3) * 10





def dfs(cur, mask):

    if cur == N:

        return calc(mask)



    res = INF

    for i in range(4):

        res = min(res, dfs(cur + 1, mask | i << (2 * cur)))

    return res





print((dfs(0, 0)))

# 4進数
N, A, B, C = list(map(int, input().split()))
l = [int(eval(input())) for _ in range(N)]
INF = float("inf")
ans = INF
for ptn in range(1 << (2 * N)):
    abc = [0 for _ in range(4)]
    v = [None for _ in range(N)]
    # lの各idxをどの竹用に割り当てるか, ABC無 = 0123
    cnt = 0
    for j in range(N):
        v[j] = (ptn >> (2 * j)) & 3
        abc[v[j]] += l[j]
        if 0 <= v[j] < 3:
            cnt += 1
    if 0 in abc[:3]:
        continue
    ans = min(ans, sum(abs(x - t) for x, t in zip(abc[:3], [A, B, C])) + (cnt - 3) * 10)
print(ans)

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


def calc(mask):
    abc = [0 for _ in range(4)]
    cnt = 0
    for j in range(N):
        idx = (mask >> (2 * j)) & 3
        abc[idx] += l[j]
        if 0 <= idx < 3:
            cnt += 1
    if 0 in abc[:3]:
        return INF
    return sum(abs(x - t) for x, t in zip(abc, [A, B, C])) + (cnt - 3) * 10


def dfs(cur, mask):
    if cur == N:
        return calc(mask)
    res = INF
    for i in range(4):
        res = min(res, dfs(cur + 1, mask | i << (2 * cur)))
    return res


print((dfs(0, 0)))

-# 4進数 +# dfs -ans = INF -for ptn in range(1 << (2 * N)): + + +def calc(mask): -    v = [None for _ in range(N)] -    # lの各idxをどの竹用に割り当てるか, ABC無 = 0123 -        v[j] = (ptn >> (2 * j)) & 3 -        abc[v[j]] += l[j] -        if 0 <= v[j] < 3: +        idx = (mask >> (2 * j)) & 3 +        abc[idx] += l[j] +        if 0 <= idx < 3: -        continue -    ans = min(ans, sum(abs(x - t) for x, t in zip(abc[:3], [A, B, C])) + (cnt - 3) * 10) -print(ans) +        return INF +    return sum(abs(x - t) for x, t in zip(abc, [A, B, C])) + (cnt - 3) * 10 + + +def dfs(cur, mask): +    if cur == N: +        return calc(mask) +    res = INF +    for i in range(4): +        res = min(res, dfs(cur + 1, mask | i << (2 * cur))) +    return res + + +print((dfs(0, 0)))