N,a,b,c=map(int,input().split())
L=[int(input()) for i in range(N)]
import itertools 
ans=300000
for i in itertools.product('ABCD',repeat=N):
  cst=0
  A=[]
  B=[]
  C=[]
  for j in range(N):
    if i[j]=='A':
      A.append(L[j])
    elif i[j]=='B':
      B.append(L[j]) 
    elif i[j]=='C':
      C.append(L[j])
  if len(A)>0 and len(B)>0 and len(C)>0:
    if len(A)>1:
      cst+=len(A)-1
    cst+=abs(sum(A)-a)
    if len(B)>1:
      cst+=len(B)-1
    cst+=abs(sum(B)-b)
    if len(C)>1:
      cst+=len(C)-1
    cst+=abs(sum(C)-c)
    ans=min(ans,cst)
 
print(ans)
   