fun main(args: Array<String>){
    val (n, A, B, C) = readLine()!!.split(" ").map(String::toInt)
    var l : MutableList<Int> = mutableListOf()
    for (i in 0..(n-1)) {
        l.add(readLine()!!.toInt())
    }

    println(dfs(0, 0, 0, 0, n, A, B, C, l))
}

fun dfs(cur : Int, a : Int, b : Int, c : Int, n : Int, A : Int, B : Int, C : Int, l : List<Int>) : Int{
    val INF = 1000000000
    if(cur == n) return if(minOf(a, b, c) > 0) Math.abs(a - A) + Math.abs(b - B) + Math.abs(c - C) - 30 else INF
    val ret0 = dfs(cur + 1, a, b, c, n, A, B, C, l)
    val ret1 = dfs(cur + 1, a + l[cur], b, c, n, A, B, C, l) + 10
    val ret2 = dfs(cur + 1, a, b + l[cur], c, n, A, B, C, l) + 10
    val ret3 = dfs(cur + 1, a, b, c + l[cur], n, A, B, C, l) + 10
    return minOf(ret0, minOf(ret1, ret2, ret3))
}