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

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



ans = float('inf')

for i in range(1<<N):

    for j in range(1<<N):

        a,b,c = [],[],[]

        cost = 0

        for keta in range(N):

            bit_i = i&(1<<keta)

            bit_j = j&(1<<keta)

            if bit_i==0 and bit_j==0:

                a.append(keta)

            elif bit_i==0 and bit_j>0:

                b.append(keta)

            elif bit_i>0 and bit_j==0:

                c.append(keta)

            else:

                pass

        if a==[] or b==[] or c==[]:

            continue

        cost += 10*(len(a)+len(b)+len(c)-3)

        for l,val in zip([a,b,c],

                         [A,B,C]):

            s = sum([L[li] for li in l])

            cost += abs(s-val)

        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 = float('inf')

for p in product(list(range(4)), repeat=N): # 4^Nループ

    take = [[] for _ in range(4)] # [A,B,C,使わない]

    for i in range(N):

        take[p[i]].append(L[i])

    a,b,c = take[0],take[1],take[2]

    if len(a)*len(b)*len(c)==0:

        continue 

    cost = (len(a)+len(b)+len(c)-3)*10

    cost += abs(sum(a)-A)+abs(sum(b)-B)+abs(sum(c)-C)

    ans = min(ans, cost)

print(ans)
N, A, B, C = list(map(int, input().split()))
L = [int(eval(input())) for _ in range(N)]
ans = float("inf")
for i in range(1 << N):
    for j in range(1 << N):
        a, b, c = [], [], []
        cost = 0
        for keta in range(N):
            bit_i = i & (1 << keta)
            bit_j = j & (1 << keta)
            if bit_i == 0 and bit_j == 0:
                a.append(keta)
            elif bit_i == 0 and bit_j > 0:
                b.append(keta)
            elif bit_i > 0 and bit_j == 0:
                c.append(keta)
            else:
                pass
        if a == [] or b == [] or c == []:
            continue
        cost += 10 * (len(a) + len(b) + len(c) - 3)
        for l, val in zip([a, b, c], [A, B, C]):
            s = sum([L[li] for li in l])
            cost += abs(s - val)
        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 = float("inf")
for p in product(list(range(4)), repeat=N):  # 4^Nループ
    take = [[] for _ in range(4)]  # [A,B,C,使わない]
    for i in range(N):
        take[p[i]].append(L[i])
    a, b, c = take[0], take[1], take[2]
    if len(a) * len(b) * len(c) == 0:
        continue
    cost = (len(a) + len(b) + len(c) - 3) * 10
    cost += abs(sum(a) - A) + abs(sum(b) - B) + abs(sum(c) - C)
    ans = min(ans, cost)
print(ans)

+from itertools import product + -for i in range(1 << N): -    for j in range(1 << N): -        a, b, c = [], [], [] -        cost = 0 -        for keta in range(N): -            bit_i = i & (1 << keta) -            bit_j = j & (1 << keta) -            if bit_i == 0 and bit_j == 0: -                a.append(keta) -            elif bit_i == 0 and bit_j > 0: -                b.append(keta) -            elif bit_i > 0 and bit_j == 0: -                c.append(keta) -            else: -                pass -        if a == [] or b == [] or c == []: -            continue -        cost += 10 * (len(a) + len(b) + len(c) - 3) -        for l, val in zip([a, b, c], [A, B, C]): -            s = sum([L[li] for li in l]) -            cost += abs(s - val) -        ans = min(ans, cost) +for p in product(list(range(4)), repeat=N):  # 4^Nループ +    take = [[] for _ in range(4)]  # [A,B,C,使わない] +    for i in range(N): +        take[p[i]].append(L[i]) +    a, b, c = take[0], take[1], take[2] +    if len(a) * len(b) * len(c) == 0: +        continue +    cost = (len(a) + len(b) + len(c) - 3) * 10 +    cost += abs(sum(a) - A) + abs(sum(b) - B) + abs(sum(c) - C) +    ans = min(ans, cost)