n,a,b,c = map(int,input().split())
l = [int(input()) for i in range(n)]

ans = 100000000000000
for i1 in range(4):
  for i2 in range(4):
    for i3 in range(4):
      for i4 in range(4):
        for i5 in range(4):
          for i6 in range(4):
            for i7 in range(4):
              for i8 in range(4):
                tmpa = 0
                tmpb = 0
                tmpc = 0
                counta=0
                countb=0
                countc=0
                if len(l)>=1:
                  if i1 ==0:
                    tmpa += l[0]
                    counta +=1
                  if i1 ==1:
                    tmpb += l[0]
                    countb +=1
                  if i1 ==2:
                    tmpc += l[0]
                    countc +=1
                if(len(l)>=2) :                 
                  if i2 ==0:
                    tmpa += l[1]
                    counta +=1
                  if i2 ==1:
                    tmpb += l[1]
                    countb +=1
                  if i2 ==2:
                    tmpc += l[1]
                    countc +=1
                if(len(l)>=3) :                 
                  if i3 ==0:
                    tmpa += l[2]
                    counta +=1
                  if i3 ==1:
                    tmpb += l[2]
                    countb +=1
                  if i3 ==2:
                    tmpc += l[2]
                    countc +=1
                if(len(l)>=4):               
                  if i4 ==0:
                    tmpa += l[3]
                    counta +=1
                  if i4 ==1:
                    tmpb += l[3]
                    countb +=1
                  if i4 ==2:
                    tmpc += l[3]  
                    countc +=1
                if(len(l)>=5) :                 
                  if i5 ==0:
                    tmpa += l[4]
                    counta +=1
                  if i5 ==1:
                    tmpb += l[4]
                    countb +=1
                  if i5 ==2:
                    tmpc += l[4]
                    countc +=1
                if(len(l)>=6):                  
                  if i6 ==0:
                    tmpa += l[5]
                    counta +=1
                  if i6 ==1:
                    tmpb += l[5]
                    countb +=1
                  if i6 ==2:
                    tmpc += l[5]
                    countc +=1
                if(len(l)>=7) :                 
                  if i7 ==0:
                    tmpa += l[6]
                    counta +=1
                  if i7 ==1:
                    tmpb += l[6]
                    countb +=1
                  if i7 ==2:
                    tmpc += l[6]
                    countc +=1
                if(len(l)>=8):                  
                  if i8 ==0:
                    tmpa += l[7]
                    counta +=1
                  if i8 ==1:
                    tmpb += l[7]
                    countb +=1
                  if i8 ==2:
                    tmpc += l[7]
                    countc +=1
                if counta>=1 and countb>=1 and countc>=1:
                   ans = min(ans,(counta-1)*(10)+(countb-1)*(10)+(countc-1)*(10)+abs(tmpa-a)+abs(tmpb-b)+abs(tmpc-c))
print(ans)
                 

Measured memory_bytes: 3192