program ccc
implicit none

integer :: n, a, b, c, i, j, k, res1, res2
integer :: a1,a2,b1,b2,c1,c2,d1,d2
integer,allocatable,dimension(:) :: l

read*, n,a,b,c
allocate(l(n))
read*, l

res2=1000000

do i=0,2**n-1
 
 do j=0,2**n-1
 a1=0
 b1=0
 c1=0
 d1=0
 a2=0
 b2=0
 c2=0
 d2=0
 res1=0
  
  do k=0,n-1
  if(btest(i,k)) then
   if(btest(j,k)) then
   a1=a1+l(k+1)
   a2=a2+1
   else
   b1=b1+l(k+1)
   b2=b2+1
   end if
  else
   if(btest(j,k)) then
   c1=c1+l(k+1)
   c2=c2+1
   else
   d1=d1+l(k+1)
   d2=d2+1
   end if
  end if
  end do
  
 if(a2==0) cycle
 if(b2==0) cycle
 if(c2==0) cycle
 res1=res1+(a2+b2+c2-3)*10
 res1=res1+abs(a-a1)+abs(b-b1)+abs(c-c1)
 res2=min(res1,res2)

 end do
end do

write(*,'(i0)') res2

end program