import java.util.Scanner

object Main {
  val sc = new Scanner(System.in)
  def main(args: Array[String]): Unit = {


    val n = sc.nextInt
    val a = sc.nextInt
    val b = sc.nextInt
    val c = sc.nextInt

    val iSeq = Seq(a,b,c)

    val ll = List.fill(n)(sc.nextInt)
    
    val target = (1 to Math.pow(4,n).toInt).map{l => s"%0${n}d".format(l_adic(l,4).mkString.toInt)}.filter{s => s.contains('1') && s.contains('2') && s.contains('3')}
    
    val res =
      target.foldLeft(Int.MaxValue){ case (min, str) =>
        val temp = str zip ll
        val sum = temp.filter(t => t._1 != '0').foldLeft( Array((0,0),(0,0),(0,0)) ){case (arr, (i,num)) =>
          i match{
            case '1' => val x = arr(0); arr.update(0, (x._1 + num, x._2 + 1) ) ; arr
            case '2' => val x = arr(1); arr.update(1, (x._1 + num, x._2 + 1) ) ; arr
            case '3' => val x = arr(2); arr.update(2, (x._1 + num, x._2 + 1) ) ; arr
          }
        }
        val sumSeq = sum.map(_._1).toSeq
        val jointNum = sum.map(_._2 - 1).sum
        if( sumSeq.count(_ == 0 ) > 0) min
        else {
          Math.min( (sumSeq zip iSeq).map(t => Math.abs(t._1 - t._2)).sum + 10 * jointNum, min)
        }
      }
    println(res)
  }

  def l_adic(n: Int, l: Int): List[Int] ={
    def loop(m: Int, acc: List[Int]): List[Int] ={
      m match {
        case 0 => acc
        case x => loop( x / l, (x % l) +: acc)
      }
    }
    loop(n,List.empty[Int])
  }
}