(* O(4^n) *)
let n, a, b, c = Scanf.scanf " %d %d %d %d" @@ fun n a b c -> n, a, b, c
let ls = Array.init n @@ fun _ -> Scanf.scanf " %d" @@ (+) 0
let to_s = Array.make n 0
let rec loop mp i a' b' c' =
  if i >= n then
    if a' > 0 && b' > 0 && c' > 0 then mp - 30 + abs (a - a') + abs (b - b') + abs (c - c')
    else max_int
  else
    let l = ls.(i) in
    min (loop (mp + 10) (i + 1) (a' + l) b' c') @@
      min (loop (mp + 10) (i + 1) a' (b' + l) c') @@
        min (loop (mp + 10) (i + 1) a' b' (c' + l)) @@ loop mp (i + 1) a' b' c'
let _ = loop 0 0 0 0 0 |> Printf.printf "%d\n"