let () = Scanf.scanf "%d %d %d %d\n" @@ fun n a b c ->
  let ls = Array.init n @@ fun _ -> Scanf.scanf "%d\n" @@ fun l -> l in
  Array.fold_left (fun (candidates : (int * int * int * int) list) l ->
    List.concat @@ List.map (fun (n, a, b, c) ->
      [(n, a, b, c);
       (n + (if 0 < a then 10 else 0), a + l, b, c);
       (n + (if 0 < b then 10 else 0), a, b + l, c);
       (n + (if 0 < c then 10 else 0), a, b, c + l)]) candidates)
  [(0, 0, 0, 0)] ls
  |> List.filter (fun (n, a, b, c) -> 0 < a && 0 < b && 0 < c)
  |> List.map (fun (n, a', b', c') ->
      n + abs (a' - a) + abs (b' - b) + abs (c' - c))
  |> List.fold_left min max_int
  |> Printf.printf "%d\n"