import java.util.Scanner

object Main {
  val sc = new Scanner(System.in)
  def main(args: Array[String]): Unit = {
    
    val n = sc.nextInt
    val (a,b,c) = (sc.nextInt, sc.nextInt, sc.nextInt)
    val ll = Seq.fill(n)(sc.nextInt)
    val nn = Math.pow(4, n).toInt
    
    val target = (1 until nn).toArray.map(l => zeroEmbeddingtoString(l.toBinaryString, 2 * n))

    val res =
      target.foldLeft(Int.MaxValue){(min, bin) =>
        def culcSum(strBin: String, sums: (Int, Int, Int), useCount: (Int, Int, Int), ll: Seq[Int]) :( (Int, Int, Int), (Int, Int, Int)) ={
          if (strBin.isEmpty) (sums, useCount)
          else strBin.substring(0,2) match{
            case "01" => culcSum(strBin.substring(2), sums.copy(sums._1 + ll.head,sums._2          , sums._3          ), useCount.copy(useCount._1 + 1, useCount._2     , useCount._3    ), ll.tail)
            case "10" => culcSum(strBin.substring(2), sums.copy(sums._1          ,sums._2 + ll.head, sums._3          ), useCount.copy(useCount._1    , useCount._2 + 1 , useCount._3    ), ll.tail)
            case "11" => culcSum(strBin.substring(2), sums.copy(sums._1          ,sums._2          , sums._3 + ll.head), useCount.copy(useCount._1    , useCount._2     , useCount._3 + 1), ll.tail)
            case _    => culcSum(strBin.substring(2), sums, useCount, ll.tail)
          }
        }
        
        val temp = culcSum(bin, (0,0,0), (0,0,0), ll)
        val ((s1,s2,s3), (c1,c2,c3)) = temp

        if(c1 * c2 * c3 == 0) min
        else{
          val sum =
            Math.abs(a - s1) + Math.abs(b - s2) + Math.abs(c - s3) +
              ( (if(c1 != 0) c1 - 1 else 0) + (if(c2 != 0) c2 - 1 else 0) + (if(c3 != 0) c3 - 1 else 0) ) * 10
          Math.min(min,sum)
        }
      }

    println(res)
  }

  def zeroEmbeddingtoString(str: String, index: Int): String ={
    val l = str.length
    List.fill(index - l)("0").mkString + str
  }
}