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

L = []

for _ in range(N):

    L.append(int(eval(input())))



ans = float('inf')

for mask in range(pow(4, N)):

    cost = 0

    for i, l in enumerate([A, B, C]):

        grp = []

        for digit in range(N):

            if mask // pow(4, digit) % 4 == i:

                grp.append(L[digit])



        if not grp:

            cost = float('inf')



        cost += (len(grp) - 1) * 10

        cost += abs(l - sum(grp))

    ans = min(ans, cost)



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**18

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

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

    for i, l in enumerate(L):

        K[state[i]].append(l)



    cost = 0

    for d, D in zip((A, B, C), K):

        if len(D) == 0:

            cost += 10**18

        cost += (len(D) - 1) * 10

        cost += abs(d - sum(D))

    ans = min(ans, cost)



print(ans)

N, A, B, C = list(map(int, input().split()))
L = []
for _ in range(N):
    L.append(int(eval(input())))
ans = float("inf")
for mask in range(pow(4, N)):
    cost = 0
    for i, l in enumerate([A, B, C]):
        grp = []
        for digit in range(N):
            if mask // pow(4, digit) % 4 == i:
                grp.append(L[digit])
        if not grp:
            cost = float("inf")
        cost += (len(grp) - 1) * 10
        cost += abs(l - sum(grp))
    ans = min(ans, cost)
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**18
for state in product(list(range(4)), repeat=N):
    K = [[] for _ in range(4)]
    for i, l in enumerate(L):
        K[state[i]].append(l)
    cost = 0
    for d, D in zip((A, B, C), K):
        if len(D) == 0:
            cost += 10**18
        cost += (len(D) - 1) * 10
        cost += abs(d - sum(D))
    ans = min(ans, cost)
print(ans)

+from itertools import product + -L = [] -for _ in range(N): -    L.append(int(eval(input()))) -ans = float("inf") -for mask in range(pow(4, N)): +L = [int(eval(input())) for _ in range(N)] +ans = 10**18 +for state in product(list(range(4)), repeat=N): +    K = [[] for _ in range(4)] +    for i, l in enumerate(L): +        K[state[i]].append(l) -    for i, l in enumerate([A, B, C]): -        grp = [] -        for digit in range(N): -            if mask // pow(4, digit) % 4 == i: -                grp.append(L[digit]) -        if not grp: -            cost = float("inf") -        cost += (len(grp) - 1) * 10 -        cost += abs(l - sum(grp)) +    for d, D in zip((A, B, C), K): +        if len(D) == 0: +            cost += 10**18 +        cost += (len(D) - 1) * 10 +        cost += abs(d - sum(D))