fun main(args: Array<String>) = println(run {
    val (n,a,b,c) = readLine()!!.split(" ").map { it.toInt() }
    val l = (1..n).map { readLine()!!.toInt() }

    var min = Int.MAX_VALUE
    fun dfs(list: List<Int>) {
        if(list.size < n) return (0..3).forEach { dfs(list+it) }
        if((1..3).any { it !in list }) return
        println(list)
        val len = IntArray(4)
        var mp = 0
        for (i in list.indices) {
            if(list[i]!=0) {
                if(len[list[i]]!=0) mp += 10
                len[list[i]] += l[i]
            }
        }
        mp += Math.abs(a-len[1]) + Math.abs(b-len[2]) + Math.abs(c-len[3])
        min = Math.min(min, mp)
    }
    dfs(emptyList())
    min

})