open Printf
open Scanf

let read_int _ = scanf " %d " (fun x -> x)

let next u =
  let rec next' = function
    | [] -> (true,[])
    | x::xs -> let (c,u') = next' xs in
      if c
      then if x < 3 then (false,(x+1)::u') else (true,0::u')
      else (false,x::u') in
  let (c,u') = next' u in
  if c then None else Some u'

let calc lu a b c =
  let (a',b',c',k') = List.fold_left (fun (a,b,c,k) (l,v) ->
      match v with
      | 0 -> (a+l,b,  c,  k+1)
      | 1 -> (a,  b+l,c,  k+1)
      | 2 -> (a,  b,  c+l,k+1)
      | _ -> (a,  b,  c,  k  )
    ) (0,0,0,0) lu in
  if a' = 0 || b' = 0 || c' = 0
  then max_int
  else abs (a-a') + abs(b-b') + abs(c-c') + 10*(k'-3)

let f l ini a b c =
  let rec f' u accum =
    let accum' = min (calc (List.combine l u) a b c) accum in
    match next u with
    | None -> accum'
    | Some u' -> f' u' accum' in
  f' ini max_int

let () =
  let n,a,b,c = scanf " %d %d %d %d " (fun n a b c -> (n,a,b,c)) in
  let l = Array.(init n read_int |> to_list) in
  let ini = Array.(make n 0 |> to_list) in
  printf "%d\n" @@ f l ini a b c
