program abc119c
  implicit none
  integer n, a, b, c, mp, i, m, ix, bamboo(3)
  integer, allocatable :: l(:), ans(:)

  read *, n, a, b, c
  allocate(l(n), ans(4**n))
  read *, l
  ans = 10**9
  do i = 1, 4**n
     mp = 0
     bamboo = 0
     do m = 1, n
        ix = iand(ishft(i - 1, -(m - 1) * 2), 3)
        if (ix /= 0) then
           bamboo(ix) = bamboo(ix) + l(m)
           mp = mp + 10
        end if
     end do
     if (any(bamboo == 0)) then
        cycle
     end if
     ans(i) = mp + sum(abs(bamboo - [a, b, c])) - 30
  end do
  print *, minval(ans)
end program abc119c
