import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = sc.nextInt()
    val b = sc.nextInt()
    val c = sc.nextInt()
    val l = IntArray(n) { sc.nextInt() }.toList()

    data class Len(val length: Int, val count: Int) {
        fun needMp(t: Int) = Math.abs(t - length) + (count - 1) * 10
        fun add(t: Int) = Len(length + t, count + 1)
    }


    fun calcMp(x: Len, y: Len, z: Len): Int {
        if (x.count == 0 || y.count == 0 || z.count == 0) return Int.MAX_VALUE
        val t = listOf(a, b, c)
        return t.map i@{ i ->
            t.map j@{ j ->
                t.map k@{ k ->
                    if (i == j || i == k || j == k) return@k Int.MAX_VALUE
                    x.needMp(i) + y.needMp(j) + z.needMp(k)

                }
            }.flatten()
        }.flatten()
            .min()!!
    }

    fun rec(x: Len, y: Len, z: Len, r: List<Int>): Int {
        if (r.isEmpty()) {
            return calcMp(x, y, z)
        }

        val nr = r.drop(1)
        val next = r.first()
        return listOf(
            rec(x, y, z, nr),
            rec(x.add(next), y, z, nr),
            rec(x, y.add(next), z, nr),
            rec(x, y, z.add(next), nr)
        ).min()!!
    }

    val ret = rec(Len(0, 0), Len(0, 0), Len(0, 0), l)
    println(ret)
}

