program name
    implicit none
    integer(4):: n,a,b,c
    integer(4),allocatable:: l(:),to(:)
    integer(4):: i,j,ni,mdl
    integer(4):: gcost, al(0:2), ans
    logical:: all(0:2)


    read*, n,a,b,c
    allocate(l(n),to(n))
    do i=1,n
        read*, l(i)
    end do
    ans = 1000000000
    do i=0,4**n-1
        ni = i
        all(:) = .false.
        do j=1,n
            to(j) = mod(ni,4)
            if (to(j) < 3) all(to(j)) = .true.
            ni=ni/4
        end do
        if (.not. (all(0) .and. all(1) .and. all(2))) cycle
        gcost = 0
        al(:) = 0
        do j=1,n
            if (to(j) == 3) cycle
            if (al(to(j)) == 0) then
                al(to(j)) = l(j)
            else
                al(to(j)) = al(to(j))+l(j)
                gcost=gcost+10
            end if
        end do


        gcost=gcost+abs(al(0)-a)
        gcost=gcost+abs(al(1)-b)
        gcost=gcost+abs(al(2)-c)
        ans = min(ans,gcost)
    end do

    print*, ans

contains
subroutine swap(x,y)
    integer(4):: x,y,t
    t=x
    x=y
    y=t
end subroutine
end program name