object Main {

  val amari = 1000000007

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val N, A, B, C = sc.nextInt()
    val L = Array.fill(N)(sc.nextInt())
    println(calc(L, Nil ,Nil, Nil))

    def calc(array: Array[Int], l1: List[Int], l2: List[Int], l3: List[Int]): Int = {
      if (array.isEmpty) {
        if (l1.isEmpty || l2.isEmpty || l3.isEmpty) {
          Int.MaxValue
        } else {
          Math.abs(l1.sum - A) + Math.abs(l2.sum - B) + Math.abs(l3.sum - C) + (l1.length + l2.length + l3.length - 3) * 10
        }
      } else {
        val h = array.head
        val t = array.tail
        Seq(
          calc(t, l1, l2, l3),
          calc(t, h :: l1, l2, l3),
          calc(t, l1, h :: l2, l3),
          calc(t, l1, l2, h :: l3)
        ).min
      }
    }
  }
}
