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
  sort compare l;
  let res = ref max_int in
  let rec solve k l sum =
    for i=0 to k-1 do
      for j=i+1 to k-1 do
        for p=j+1 to k-1 do
          let ca,cb,cc = l.(p),l.(j),l.(i) in
          let v = sum + abs (ca - a) + abs (cb - b) + abs (cc - c)
          in
          (* printf "    %2d,%2d,%2d v. %2d,%2d,%2d :: %d"
            a b c
            ca cb cc v; *)
          res := min !res v
        done
      done
    done;
    (* printf "%d(%d): [" k sum;
    iter (printf "%3d ") l;
    printf "] :: %d" !res; print_newline (); *)
    if k>3 then (
      for i=0 to k-1 do
        for j=i+1 to k-1 do
          let r = ref [] in
          for p=0 to k-1 do
            if p=i then r := (l.(i) + l.(j)) :: !r
            else if p=j then ()
            else r := l.(p) :: !r
          done;
          r := List.sort compare !r;
          solve (k-1) (of_list !r) (sum+10)
        done
      done
    )
  in solve n l 0;
  printf "%d" @@ !res