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

L = [0]*N

for i in range(N):

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



import itertools

bambuu = [[0,0,0] for _ in range(4**N)]

for i,pro in enumerate(itertools.product(['A','B',"C",'D'], repeat=N)):

    lisA = [L[j] for j in range(N) if pro[j]=='A']

    lisB = [L[j] for j in range(N) if pro[j]=='B']

    lisC = [L[j] for j in range(N) if pro[j]=='C']

    sumA = [sum(lisA),(len(lisA)-1)*10]

    sumB = [sum(lisB),(len(lisB)-1)*10]

    sumC = [sum(lisC),(len(lisC)-1)*10]

    bambuu[i-1] = [sumA,sumB,sumC]



ans = 10000

for sA,sB,sC in bambuu:

    if sA[0]>0 and sB[0]>0 and sC[0]>0:

        mp_total = abs(A-sA[0])+abs(B-sB[0])+abs(C-sC[0])+sA[1]+sB[1]+sC[1]

        if mp_total < ans:

            #record = [sA,sB,sC]

            ans = mp_total

#print(record)

print(ans)

#print(*ans, sep='\n')
from itertools import groupby, accumulate, product, permutations, combinations

def calc(x,X):

  n = len(x)

  ans = 10**10

  for q in product([0,1],repeat=n):

    point = 0

    cnt = 0

    for i in range(n):

      if q[i]==1:

        if cnt>0:

          point += 10

        cnt += x[i]

    if cnt>0:

      point += abs(cnt-X)

    else:

      point = 10**10

    ans = min(point,ans)

  return ans



def solve():

  ans = 10**10

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

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

  for p in product(['A','B','C','D'],repeat=N):

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

    cnt = 0

    for i in range(N):

      if p[i]=='A':

        a.append(L[i])

      elif p[i]=='B':

        b.append(L[i])

      elif p[i]=='C':

        c.append(L[i])

    cnt += calc(a,A)+calc(b,B)+calc(c,C)

    ans = min(ans,cnt)

  return ans

print((solve()))
N, A, B, C = list(map(int, input().split()))
L = [0] * N
for i in range(N):
    L[i] = int(eval(input()))
import itertools

bambuu = [[0, 0, 0] for _ in range(4**N)]
for i, pro in enumerate(itertools.product(["A", "B", "C", "D"], repeat=N)):
    lisA = [L[j] for j in range(N) if pro[j] == "A"]
    lisB = [L[j] for j in range(N) if pro[j] == "B"]
    lisC = [L[j] for j in range(N) if pro[j] == "C"]
    sumA = [sum(lisA), (len(lisA) - 1) * 10]
    sumB = [sum(lisB), (len(lisB) - 1) * 10]
    sumC = [sum(lisC), (len(lisC) - 1) * 10]
    bambuu[i - 1] = [sumA, sumB, sumC]
ans = 10000
for sA, sB, sC in bambuu:
    if sA[0] > 0 and sB[0] > 0 and sC[0] > 0:
        mp_total = (
            abs(A - sA[0]) + abs(B - sB[0]) + abs(C - sC[0]) + sA[1] + sB[1] + sC[1]
        )
        if mp_total < ans:
            # record = [sA,sB,sC]
            ans = mp_total
# print(record)
print(ans)
# print(*ans, sep='\n')

from itertools import groupby, accumulate, product, permutations, combinations


def calc(x, X):
    n = len(x)
    ans = 10**10
    for q in product([0, 1], repeat=n):
        point = 0
        cnt = 0
        for i in range(n):
            if q[i] == 1:
                if cnt > 0:
                    point += 10
                cnt += x[i]
        if cnt > 0:
            point += abs(cnt - X)
        else:
            point = 10**10
        ans = min(point, ans)
    return ans


def solve():
    ans = 10**10
    N, A, B, C = list(map(int, input().split()))
    L = [int(eval(input())) for _ in range(N)]
    for p in product(["A", "B", "C", "D"], repeat=N):
        a, b, c = [], [], []
        cnt = 0
        for i in range(N):
            if p[i] == "A":
                a.append(L[i])
            elif p[i] == "B":
                b.append(L[i])
            elif p[i] == "C":
                c.append(L[i])
        cnt += calc(a, A) + calc(b, B) + calc(c, C)
        ans = min(ans, cnt)
    return ans


print((solve()))

-N, A, B, C = list(map(int, input().split())) -L = [0] * N -for i in range(N): -    L[i] = int(eval(input())) -import itertools +from itertools import groupby, accumulate, product, permutations, combinations -bambuu = [[0, 0, 0] for _ in range(4**N)] -for i, pro in enumerate(itertools.product(["A", "B", "C", "D"], repeat=N)): -    lisA = [L[j] for j in range(N) if pro[j] == "A"] -    lisB = [L[j] for j in range(N) if pro[j] == "B"] -    lisC = [L[j] for j in range(N) if pro[j] == "C"] -    sumA = [sum(lisA), (len(lisA) - 1) * 10] -    sumB = [sum(lisB), (len(lisB) - 1) * 10] -    sumC = [sum(lisC), (len(lisC) - 1) * 10] -    bambuu[i - 1] = [sumA, sumB, sumC] -ans = 10000 -for sA, sB, sC in bambuu: -    if sA[0] > 0 and sB[0] > 0 and sC[0] > 0: -        mp_total = ( -            abs(A - sA[0]) + abs(B - sB[0]) + abs(C - sC[0]) + sA[1] + sB[1] + sC[1] -        ) -        if mp_total < ans: -            # record = [sA,sB,sC] -            ans = mp_total -# print(record) -print(ans) -# print(*ans, sep='\n') + +def calc(x, X): +    n = len(x) +    ans = 10**10 +    for q in product([0, 1], repeat=n): +        point = 0 +        cnt = 0 +        for i in range(n): +            if q[i] == 1: +                if cnt > 0: +                    point += 10 +                cnt += x[i] +        if cnt > 0: +            point += abs(cnt - X) +        else: +            point = 10**10 +        ans = min(point, ans) +    return ans + + +def solve(): +    ans = 10**10 +    N, A, B, C = list(map(int, input().split())) +    L = [int(eval(input())) for _ in range(N)] +    for p in product(["A", "B", "C", "D"], repeat=N): +        a, b, c = [], [], [] +        cnt = 0 +        for i in range(N): +            if p[i] == "A": +                a.append(L[i]) +            elif p[i] == "B": +                b.append(L[i]) +            elif p[i] == "C": +                c.append(L[i]) +        cnt += calc(a, A) + calc(b, B) + calc(c, C) +        ans = min(ans, cnt) +    return ans + + +print((solve()))