type ABC(stream:System.IO.TextReader) =
  member this.Scan1 f = stream.ReadLine() |> f
  member this.Scan2 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1]))
  member this.Scan3 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2]))
  member this.Scan4 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2], a.[3]))
  member this.ScanVecH f = stream.ReadLine().Split() |> Array.map f
  member this.ScanVecV n f = [| for i in 1..n -> stream.ReadLine() |> f |]
  member this.ScanMatrix n f  = [ for i in 1..n do yield stream.ReadLine().Split() |> Array.map f ]
  member this.ScanCharMatrix n = [| for i in 1..n -> stream.ReadLine().ToCharArray() |]
  member this.Close () = stream.Close()

let util = ABC(stdin)

let N,A,B,C = util.Scan4 int
let xs = util.ScanVecV N int
let BIG = pown 10 9

let rec cost n a b c =
  if n = N
  then // 全ての竹について選択が完了
    if List.exists ((=) 0) [a;b;c] // 一つも材料が無いやつは除外
    then BIG
    else -30 + (List.sumBy abs [a-A;b-B;c-C]) // 端数は伸縮魔法で調整, -10 を補正で入れる(最初の結合にはMP10を使用しない)
  else
    let c1 = cost (n+1) a b c // 非選択
    let c2 = 10 + (cost (n+1) (a+xs.[n]) b c) // Aの材料に
    let c3 = 10 + (cost (n+1) a (b+xs.[n]) c)
    let c4 = 10 + (cost (n+1) a b (c+xs.[n]))
    List.min [c1;c2;c3;c4]

cost 0 0 0 0
|> printfn "%d"
