integer N
integer A,B,C
integer,allocatable,dimension(:)::L
read*,N,A,B,C
allocate(L(N))
read*,L
print"(I0)",dfs(N,0,0,0)

contains
recursive function dfs(nokori,forA,forB,forC)result(res)
  integer,intent(in)::nokori,forA,forB,forC
  integer res
  if(nokori==0)then
    res=abs(A-forA)+abs(B-forB)+abs(C-forC)-10*3
	if(forA*forB*forC==0)res=huge(res)/2
  else
    res=dfs(nokori-1,forA,forB,forC)
    res=min(res,dfs(nokori-1,forA+L(nokori),forB,forC)+10)
    res=min(res,dfs(nokori-1,forA,forB+L(nokori),forC)+10)
    res=min(res,dfs(nokori-1,forA,forB,forC+L(nokori))+10)
  endif
end function
end