import itertools



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

comb = [] #0:使用しない,1:竹Aの材料,2:竹Bの材料,3:竹Cの材料

L = []

for i in range(N):

  l = int(eval(input()))

  L.append(l)

  comb.append([0,1,2,3])



All_comb =  list(itertools.product(*comb))

min_MP = float('inf')

for i in range(len(All_comb)):

  tmp = All_comb[i]

  Non_material = []

  A_material = []

  B_material = []

  C_material = []

  for j in range(len(tmp)):

    if(tmp[j] == 0): Non_material.append(L[j])

    elif(tmp[j] == 1): A_material.append(L[j])

    elif(tmp[j] == 2): B_material.append(L[j])

    elif(tmp[j] == 3): C_material.append(L[j])

    a,b,c = len(A_material),len(B_material),len(C_material)

    if((a>=1)and(b>=1)and(c>=1)):

     sum_A,sum_B,sum_C = sum(A_material),sum(B_material),sum(C_material)

     MP = abs(A-sum_A)+abs(B-sum_B)+abs(C-sum_C) +10*(a+b+c-3)

     min_MP = min(MP,min_MP)



print(min_MP)

    
import itertools



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

Comb = itertools.product([0,1,2,3],repeat=N)



L = []

for i in range(N):

  l = int(eval(input()))

  L.append(l)

  

# 各竹について  

# 0 : 使用しない

# 1 : 竹Aの材料にする  

# 2 : 竹Bの材料にする 

# 3 : 竹Cの材料にする

# 竹A,B,Cの作成法 :

# とりあえず全部合成 → 目的の長さに合わせる



ans = float('inf')

for X in Comb:

  tmp = 0

  m_A,m_B,m_C = [],[],[]

  for i in range(N):

    if(X[i] == 1): m_A.append(L[i])

    elif(X[i] == 2): m_B.append(L[i])

    elif(X[i] == 3): m_C.append(L[i])

  # 空の竹リストがないなら    

  if(len(m_A)*len(m_B)*len(m_C) != 0):      

    for take_list,take_len in zip([m_A,m_B,m_C],[A,B,C]):

      tmp += (len(take_list)-1)*10 # 合成

      tmp += (abs(take_len-sum(take_list)))*1 # 延長or短縮

    ans = min(ans,tmp)

  

print(ans)  
import itertools

N, A, B, C = list(map(int, input().split()))
comb = []  # 0:使用しない,1:竹Aの材料,2:竹Bの材料,3:竹Cの材料
L = []
for i in range(N):
    l = int(eval(input()))
    L.append(l)
    comb.append([0, 1, 2, 3])
All_comb = list(itertools.product(*comb))
min_MP = float("inf")
for i in range(len(All_comb)):
    tmp = All_comb[i]
    Non_material = []
    A_material = []
    B_material = []
    C_material = []
    for j in range(len(tmp)):
        if tmp[j] == 0:
            Non_material.append(L[j])
        elif tmp[j] == 1:
            A_material.append(L[j])
        elif tmp[j] == 2:
            B_material.append(L[j])
        elif tmp[j] == 3:
            C_material.append(L[j])
        a, b, c = len(A_material), len(B_material), len(C_material)
        if (a >= 1) and (b >= 1) and (c >= 1):
            sum_A, sum_B, sum_C = sum(A_material), sum(B_material), sum(C_material)
            MP = abs(A - sum_A) + abs(B - sum_B) + abs(C - sum_C) + 10 * (a + b + c - 3)
            min_MP = min(MP, min_MP)
print(min_MP)

import itertools

N, A, B, C = list(map(int, input().split()))
Comb = itertools.product([0, 1, 2, 3], repeat=N)
L = []
for i in range(N):
    l = int(eval(input()))
    L.append(l)
# 各竹について
# 0 : 使用しない
# 1 : 竹Aの材料にする
# 2 : 竹Bの材料にする
# 3 : 竹Cの材料にする
# 竹A,B,Cの作成法 :
# とりあえず全部合成 → 目的の長さに合わせる
ans = float("inf")
for X in Comb:
    tmp = 0
    m_A, m_B, m_C = [], [], []
    for i in range(N):
        if X[i] == 1:
            m_A.append(L[i])
        elif X[i] == 2:
            m_B.append(L[i])
        elif X[i] == 3:
            m_C.append(L[i])
    # 空の竹リストがないなら
    if len(m_A) * len(m_B) * len(m_C) != 0:
        for take_list, take_len in zip([m_A, m_B, m_C], [A, B, C]):
            tmp += (len(take_list) - 1) * 10  # 合成
            tmp += (abs(take_len - sum(take_list))) * 1  # 延長or短縮
        ans = min(ans, tmp)
print(ans)

-comb = []  # 0:使用しない,1:竹Aの材料,2:竹Bの材料,3:竹Cの材料 +Comb = itertools.product([0, 1, 2, 3], repeat=N) -    comb.append([0, 1, 2, 3]) -All_comb = list(itertools.product(*comb)) -min_MP = float("inf") -for i in range(len(All_comb)): -    tmp = All_comb[i] -    Non_material = [] -    A_material = [] -    B_material = [] -    C_material = [] -    for j in range(len(tmp)): -        if tmp[j] == 0: -            Non_material.append(L[j]) -        elif tmp[j] == 1: -            A_material.append(L[j]) -        elif tmp[j] == 2: -            B_material.append(L[j]) -        elif tmp[j] == 3: -            C_material.append(L[j]) -        a, b, c = len(A_material), len(B_material), len(C_material) -        if (a >= 1) and (b >= 1) and (c >= 1): -            sum_A, sum_B, sum_C = sum(A_material), sum(B_material), sum(C_material) -            MP = abs(A - sum_A) + abs(B - sum_B) + abs(C - sum_C) + 10 * (a + b + c - 3) -            min_MP = min(MP, min_MP) -print(min_MP) +# 各竹について +# 0 : 使用しない +# 1 : 竹Aの材料にする +# 2 : 竹Bの材料にする +# 3 : 竹Cの材料にする +# 竹A,B,Cの作成法 : +# とりあえず全部合成 → 目的の長さに合わせる +ans = float("inf") +for X in Comb: +    tmp = 0 +    m_A, m_B, m_C = [], [], [] +    for i in range(N): +        if X[i] == 1: +            m_A.append(L[i]) +        elif X[i] == 2: +            m_B.append(L[i]) +        elif X[i] == 3: +            m_C.append(L[i]) +    # 空の竹リストがないなら +    if len(m_A) * len(m_B) * len(m_C) != 0: +        for take_list, take_len in zip([m_A, m_B, m_C], [A, B, C]): +            tmp += (len(take_list) - 1) * 10  # 合成 +            tmp += (abs(take_len - sum(take_list))) * 1  # 延長or短縮 +        ans = min(ans, tmp) +print(ans)