
fun main(args: Array<String>) {
    val (n, a, b, c) = readLine()!!.split(" ").map { it.toInt() }
    var ln = mutableListOf<Int>()
    for (i in 1..n){
        val j = readLine()!!.toInt()
        ln.add(j)
    }
    println(dfs(0, 0, 0, 0, n, a, b, c, ln))
}

fun dfs(cur: Int, tmp_a: Int, tmp_b: Int, tmp_c: Int, n: Int, a: Int, b: Int, c: Int, ln: List<Int>): Int {
    if (cur == n) {
        if (listOf<Int>(tmp_a, tmp_b, tmp_c).min()!! > 0) {
            return Math.abs(tmp_a - a) + Math.abs(tmp_b - b) + Math.abs(tmp_c - c) - 30
        } else {
            return 100000000
        }
    } else {
        val ret0 = dfs(cur + 1, tmp_a, tmp_b, tmp_c, n, a, b, c, ln)
        val ret1 = dfs(cur + 1, tmp_a + ln[cur], tmp_b, tmp_c, n, a, b, c, ln) + 10
        val ret2 = dfs(cur + 1, tmp_a, tmp_b + ln[cur], tmp_c, n, a, b, c, ln) + 10
        val ret3 = dfs(cur + 1, tmp_a, tmp_b, tmp_c + ln[cur], n, a, b, c, ln) + 10
        return listOf<Int>(ret0, ret1, ret2, ret3).min()!!
    }
}
