N,A,B,C = map(int,input().split())
l=[]
for i in range(N):
  l.append(int(input()))
l_sum =[]
l_sum.append(l)
for h in range(1,N):
  l_sum_temp = []
  for i in range(N):
    for j in range(N):
      l_sum_temp.append(l_sum[h-1][i] + l_sum[h-1][j])
  l_sum.append(list(set(l_sum_temp)))
MP_list_A =[]
for h in range(N):
  for i in range(len(l_sum[h])):              
    MP_A = abs(A - l_sum[h][i]) + h*10
    MP_list_A.append(MP_A)
MP = min(MP_list_A)
MP_list_B =[]
for h in range(N):
  for i in range(len(l_sum[h])):              
    MP_B = abs(B - l_sum[h][i]) + h*10
    MP_list_B.append(MP_B)
MP += min(MP_list_B)
MP_list_C =[]
for h in range(N):
  for i in range(len(l_sum[h])):              
    MP_C = abs(C - l_sum[h][i]) + h*10
    MP_list_C.append(MP_C)
MP += min(MP_list_C)
print(MP)