package atcoder.abc119

fun main(args : Array<String>) {
    val (N, A, B, C) = readLine()!!.split(" ").map { it.toInt() }
    var l = mutableListOf<Int>()
    (1..N).forEach {
        l.add(readLine()!!.toInt())
    }

    fun dfs(times: Int, sum_for_a: Int, sum_for_b: Int, sum_for_c: Int) : Int {
        if (times == N) {
            if (listOf(sum_for_a, sum_for_b, sum_for_c).min() == 0) {
                return Int.MAX_VALUE
            }
            return Math.abs((sum_for_a - A)) + Math.abs(sum_for_b - B) + Math.abs(sum_for_c - C)
        }
        val li = l[times]

        val candidate1 = dfs(times + 1, sum_for_a + li, sum_for_b, sum_for_c)
        val candidate2 = dfs(times + 1, sum_for_a + li, sum_for_b, sum_for_c) + 10
        val candidate3 = dfs(times + 1, sum_for_a , sum_for_b + li, sum_for_c) + 10
        val candidate4 = dfs(times + 1, sum_for_a , sum_for_b, sum_for_c + li) + 10

        return listOf(candidate1, candidate2, candidate3, candidate4).min()!!
    }

    println(dfs(0, 0, 0, 0) - 30)
}

