let (>>=) xs f = List.map f xs |> List.concat
let rec choice s c acc = function
  | [] -> if s = 0 then [] else [(s, c-10, acc)]
  | x::xs -> choice s c (x::acc) xs @ choice (s+x) (c+10) acc xs
let () =
  Scanf.scanf "%d %d %d %d" @@ fun n a b c ->
  let l = Array.init n (fun _ -> Scanf.scanf " %d" ((+) 0)) |> Array.to_list in
  (choice 0 0 [] l >>= fun (a', wa, l) ->
   choice 0 0 [] l >>= fun (b', wb, l) ->
   choice 0 0 [] l >>= fun (c', wc, l) ->
     [wa + wb + wc + abs (a - a') + abs (b - b') + abs (c - c')])
  |> List.fold_left min 1010101010
  |> Printf.printf "%d\n"
