let n, a, b, c = Scanf.scanf " %d %d %d %d" @@ fun a b c d -> a, b, c, d
let ls = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let rec f mp i la lb lc =
  if i >= n then if min la (min lb lc) = 0 then max_int else mp + abs (la - a) + abs (lb - b) + abs (lc - c) - 30
  else List.fold_left min (f mp (i + 1) la lb lc)
    [f (mp + 10) (i + 1) (la + ls.(i)) lb lc; f (mp + 10) (i + 1) la (lb + ls.(i)) lc; f (mp + 10) (i + 1) la lb (lc + ls.(i))]
let _ = f 0 0 0 0 0 |> Printf.printf "%d\n"