open Scanf
open Printf

let (n,a,b,c) = sscanf (read_line ()) "%d %d %d %d" (fun n a b c -> (n,a,b,c))
let list = 
let rec input_list n l =
match n with 
  0 -> l
| x -> input_list (x-1) (sscanf (read_line ()) "%d" (fun x -> x):: l)
in input_list n [];;

let ans = ref 3000;;

let rec loop a_in b_in c_in mp l =
match l with
  [] -> 
  if (a_in * b_in * c_in = 0) then 3000
  else 
  let tmp = abs(a - a_in) + abs(b - b_in) + abs(c - c_in) + mp - 30 in
  let _ = ans := min !ans tmp in
  (*let _ = printf "%d %d %d\n" a_in b_in c_in in
  let _ = printf "tmp = %d\n" tmp in*)
  tmp
  | x::rest -> 
  let a_use = loop (a_in + x) b_in c_in (mp+10) rest in
  let b_use = loop a_in (b_in + x) c_in (mp+10) rest in
  let c_use = loop a_in b_in (c_in + x) (mp+10) rest in
  loop a_in b_in c_in mp rest;;

let _ = loop 0 0 0 0 list in printf ("%d\n") !ans;;
