open Printf open Scanf
open Array

let () = scanf " %d %d %d %d" @@ fun n a b c ->
  let l = init n (fun _ -> scanf " %d" @@ fun v -> v) in
  let rec solve i p q r s =
    if i=n then (
      if p>0 && q>0 && r>0 then
        (n-s-3) * 10
        + abs (p-a) + abs (q-b) + abs (r-c)
      else max_int
    )
    else
      let v = l.(i) in
      fold_left min max_int [|
        solve (i+1) (p+v) q r s;
        solve (i+1) p (q+v) r s;
        solve (i+1) p q (r+v) s;
        solve (i+1) p q r (s+1)
      |]
  in print_int @@ solve 0 0 0 0 0


