Scanf.scanf "%d %d %d %d" (fun n a b c ->
    let l = Array.init n (fun _ -> Scanf.scanf " %d" (fun l -> l)) in

    let arr = Array.make 4 0 in

    let calc_cost cost arr =
        let enl k q =
            if k = 0 then 100000 else abs (k - q)
        in
        cost + (enl arr.(0) a) + (enl arr.(1) b) + (enl arr.(2) c)
    in

    let rec loop i c cost min_cost =
        if i = n then min min_cost (calc_cost cost arr) else
            if c = 4 then min_cost else (
                arr.(c) <- arr.(c) + l.(i);
                let newcost = if c = 3 || arr.(c) = l.(i) then cost else cost + 10 in
                let mi = loop (i + 1) 0 newcost min_cost in
                arr.(c) <- arr.(c) - l.(i);
                loop i (c + 1) cost mi
            )
    in
    loop 0 0 0 max_int |> Printf.printf "%d\n"
)