n,a,b,c=map(int,input().split())
l=[]
for i in range(n):
  l.append(int(input()))
list2=[]
s=0
for i in range(4):
  list=[0,0,0,0]
  list[i]+=l[0]
  if i!=3:
    s+=10
  for j in range(4):
    list[j]+=l[1]
    if j!=3:
      s+=10
      for o in range(4):
        list[o]+=l[2]
        if o!=3:
          s+=10
          for p in range(4):
            list[p]+=l[3]
            if p!=3:
              s+=10
              for u in range(4):
                list[u]+=l[4]
                if u!=3:
                  s+=10                 
                  for t in range(4):
                    list[t]+=l[5]
                    if t!=3:
                      s+=10
                      for r in range(4):
                        list[r]+=l[6]
                        if r!=3:
                          s+=10
                          for q in range(4):
                            list[q]+=l[7]
                            if q!=3:
                              s+=10
                            if list[0]==0 or list[1]==0 or list[2]==0:
                              pass
                            else:
                              list2.append(abs(a-list[0])+abs(b-list[1])+abs(c-list[2]))
print(min(list2))
                        
                      

  

  
  


           