program atcoder
    implicit none
    integer(8) :: N,A(0:2),K=1,i,j,s(0:5),cut(0:5),ans,p;
    integer(8),allocatable,dimension(:) :: L;
    read*,N,A(0),A(1),A(2)
    allocate(L(N))
    read(*,*)(L(i),i=1,N)
    do i=1,N
        K = K * 4
    enddo
    ans = 100000000000000000_8
    do j = 1,K
        s = 0
        cut = 0
        p = j
        do i = 1,N
            s(mod(p,4)) = s(mod(p,4)) + L(i)
            cut(mod(p,4)) = cut(mod(p,4)) + 1
            p = int(p/4)
        enddo
        do i=0,2
            p=p + abs(s(i)-A(i))
            p=p + (cut(i)-1)*10
            if(cut(i)==0)then
                p= 100000000000000000_8
            endif
        enddo
        ans = min(ans,p)
    enddo
    write(*,'(I0)')ans
    stop 
contains
end program atcoder