# -*- coding: utf-8 -*-

from itertools import product

def inpl(): return list(map(int, input().split()))



N, A, B, C = inpl()

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



ans = 1e9



for X in product(list(range(4)), repeat=N):

    P = [[] for _ in range(4)]

    for i, x in enumerate(X):

        P[x].append(L[i])



    if min(list(map(len, P[1:]))) == 0:

        continue



    tmp = 0

    for Q, D in zip(P[1:], [A, B, C]):

        tmp += 10*(len(Q)-1) + abs(D-sum(Q))

    if tmp < ans:

        ans = min(tmp, ans)



print(ans)

import sys

input = sys.stdin.readline



def inpl(): return list(map(int, input().split()))



N, A, B, C = inpl()

L = [0]*N

for i in range(N):

    L[i] = int(eval(input()))



ans = 10**9

for k in range(4**N):

    ABC = [0]*3

    CNT = [0]*3

    j = k*1

    for i in range(N):

        d, m = divmod(j, 4)

        if m <= 2:

            ABC[m] += L[i]

            CNT[m] += 1

        j = d

    if min(CNT) == 0:

        continue

    tmp = abs(ABC[0] - A) + abs(ABC[1] - B) + abs(ABC[2] - C) + sum([10*(cnt-1) for cnt in CNT])

    ans = min(ans, tmp)

print(ans)
# -*- coding: utf-8 -*-
from itertools import product


def inpl():
    return list(map(int, input().split()))


N, A, B, C = inpl()
L = [int(eval(input())) for _ in range(N)]
ans = 1e9
for X in product(list(range(4)), repeat=N):
    P = [[] for _ in range(4)]
    for i, x in enumerate(X):
        P[x].append(L[i])
    if min(list(map(len, P[1:]))) == 0:
        continue
    tmp = 0
    for Q, D in zip(P[1:], [A, B, C]):
        tmp += 10 * (len(Q) - 1) + abs(D - sum(Q))
    if tmp < ans:
        ans = min(tmp, ans)
print(ans)

import sys

input = sys.stdin.readline


def inpl():
    return list(map(int, input().split()))


N, A, B, C = inpl()
L = [0] * N
for i in range(N):
    L[i] = int(eval(input()))
ans = 10**9
for k in range(4**N):
    ABC = [0] * 3
    CNT = [0] * 3
    j = k * 1
    for i in range(N):
        d, m = divmod(j, 4)
        if m <= 2:
            ABC[m] += L[i]
            CNT[m] += 1
        j = d
    if min(CNT) == 0:
        continue
    tmp = (
        abs(ABC[0] - A)
        + abs(ABC[1] - B)
        + abs(ABC[2] - C)
        + sum([10 * (cnt - 1) for cnt in CNT])
    )
    ans = min(ans, tmp)
print(ans)

-# -*- coding: utf-8 -*- -from itertools import product +import sys + +input = sys.stdin.readline -L = [int(eval(input())) for _ in range(N)] -ans = 1e9 -for X in product(list(range(4)), repeat=N): -    P = [[] for _ in range(4)] -    for i, x in enumerate(X): -        P[x].append(L[i]) -    if min(list(map(len, P[1:]))) == 0: +L = [0] * N +for i in range(N): +    L[i] = int(eval(input())) +ans = 10**9 +for k in range(4**N): +    ABC = [0] * 3 +    CNT = [0] * 3 +    j = k * 1 +    for i in range(N): +        d, m = divmod(j, 4) +        if m <= 2: +            ABC[m] += L[i] +            CNT[m] += 1 +        j = d +    if min(CNT) == 0: -    tmp = 0 -    for Q, D in zip(P[1:], [A, B, C]): -        tmp += 10 * (len(Q) - 1) + abs(D - sum(Q)) -    if tmp < ans: -        ans = min(tmp, ans) +    tmp = ( +        abs(ABC[0] - A) +        + abs(ABC[1] - B) +        + abs(ABC[2] - C) +        + sum([10 * (cnt - 1) for cnt in CNT]) +    ) +    ans = min(ans, tmp)