import java.io.BufferedReader
import java.util.*
import kotlin.math.abs
import kotlin.math.min

fun main() = abc119d()

@OptIn(ExperimentalStdlibApi::class)
fun abc119d() = SimpleFastIOWithToken_abc119d().exec {
    val n = readInt()
    val abc = IntArray(3) { readInt() }
    val bamboos = IntArray(n) { readInt() }

    var answer = Int.MAX_VALUE

    searchAllPatterns(arrayOf(-1, 0, 1, 2), n) { groups ->
        val lengths = IntArray(3)
        var merge = 0
        groups.forEachIndexed { index, group ->
            if (group != -1) {
                if (lengths[group] != 0) merge++
                lengths[group] += bamboos[index]
            }
        }
        if (lengths.any { it == 0 }) return@searchAllPatterns
        val diffSum = (0..2).sumBy { abs(lengths[it] - abc[it]) }
        answer = min(answer, diffSum + merge * 10)
    }

    println(answer)
}

private inline fun <reified T> searchAllPatterns(patterns: Array<T>, length: Int, action: (Array<T>) -> Unit) {
    val patternSize = patterns.size
    val pow = (1..length).fold(1L) { acc: Long, _: Int -> acc * patternSize }
    val allPatterns = if (pow in 1..Int.MAX_VALUE) pow.toInt() else error("$pow is too large!")
    for (i in 0 until allPatterns) {
        val array = Array(length) { patterns[0] }
        var div = 1
        for (j in 0 until length) {
            array[length - j - 1] = patterns[(i / div) % patternSize]
            div *= patternSize
        }
        action(array)
    }
}

// region kokokara template dayo (^o^)
@Suppress("unused", "HasPlatformType", "MemberVisibilityCanBePrivate", "ClassName")
private class SimpleFastIOWithToken_abc119d(private val separator: String = System.lineSeparator()) {
    private val br: BufferedReader = System.`in`.bufferedReader()
    private var st: StringTokenizer = StringTokenizer("")
    private val sb: StringBuilder = StringBuilder()
    private fun prepareNext() = run { if (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) }

    fun readString(): String = run { prepareNext() }.run { st.nextToken() }
    fun readInt(): Int = Integer.valueOf(readString())
    fun readLong(): Long = java.lang.Long.valueOf(readString())

    fun println(): Unit = run { sb.append(separator) }
    fun print(any: Any): Unit = run { sb.append(any) }
    fun println(any: Any): Unit = run { sb.append(any.toString() + separator) }

    fun exec(action: SimpleFastIOWithToken_abc119d.() -> Unit) {
        var t: Throwable? = null
        Thread(null, { action() }, "solve", 128 * 1024 * 1024)
            .apply { setUncaughtExceptionHandler { _, t1 -> t = t1 } }
            .apply { start() }.join()
        t?.let { throw it }
        kotlin.io.print(sb)
    }

    fun readLine(): Nothing = error("readLine is disabled.")
}
// endregion kokomade template dayo (^o^)
