program test
implicit none

integer(8) :: a,b,c,i,j,k,ll(8),n,abcd(8)=1
integer(8) :: count(3),len(3),ans=1d10,cost
read(*,*) n,a,b,c

do i = 1,n
	read(*,*) ll(i)
enddo

do

	count(1:3) = 0
	len(1:3) = 0
	
	do j=1,n
		do k=1,3
			if(abcd(j) == k)then
				count(k) = count(k) + 1
				len(k) = len(k) + ll(j)
			endif
		enddo
	enddo
	
	
	if(minval(count(1:3)) >= 1)then
		
		cost = 10*(sum(count(1:3))-3) + abs(len(1)-a) + abs(len(2)-b) + abs(len(3)-c)
		ans = min(ans,cost)
		
	endif
	
	abcd(n) = abcd(n)+1
	
	do j=n,2,-1
		if(abcd(j)==5)then
			abcd(j) = 1
			abcd(j-1) = abcd(j-1)+1
		endif
	enddo
	
	if(abcd(1) == 5)then
		goto 100
	endif
	
enddo


100 continue
write(*,*) ans

end program
