import java.util.*
import java.math.*
import java.lang.Math.*
import kotlin.collections.ArrayList

private val readString: ()->String = {readLine()!!}
private val readInt: ()->Int = { readLine()!!.toInt() }
private val readLong: ()->Long = { readLine()!!.toLong() }
private val readListInt: ()->List<Int> = { readLine()!!.split(' ').map(String::toInt) }
private val readListLong: ()->List<Long> = { readLine()!!.split(' ').map(String::toLong) }
private val errPrintln: (String)->Unit = { msg -> System.err.println(msg) }
private val MOD = 1e9.toLong()+7
private val INF = Int.MAX_VALUE/2
private val LINF = Long.MAX_VALUE/2


var PA:Int = 0
var PB:Int = 0
var PC:Int = 0

class StateDfs(val Depth: Int, val Item: List<Int>, val StateSize: Int) {
    private data class Param(var value: Int, var count: Int)
    private data class State(val paramSize: Int, val params:Array<Param>,
                             val path: ArrayList<Int> = ArrayList())
    val INF = Int.MAX_VALUE/2
    private var curState: State
    private var ans: Int = 0
    init {
        this.curState = State(this.StateSize, Array<Param>(this.StateSize){Param(0,0)})
        this.ans = INF
    }
    private tailrec fun _dfs(n: Int, stat: State): Unit {
        if (n >= this.Depth) {
            if (stat.params[0].count>0 && stat.params[1].count>0 && stat.params[2].count>0) {
                var cost = (stat.params[0].count-1 + stat.params[1].count-1 + stat.params[2].count-1) * 10
                cost += abs(PA- stat.params[0].value) + abs(PB - stat.params[1].value) + abs(PC - stat.params[2].value)
                this.ans = min(this.ans, cost)
            }

            return
        } else {
            for(i in 0 until this.StateSize) {
                stat.params[i].value += Item[n]
                stat.params[i].count += 1
                stat.path.add(i)
                this._dfs(n + 1, stat)
                stat.params[i].value -= Item[n];
                stat.params[i].count -= 1;
                stat.path.removeAt(stat.path.lastIndex)
            }
        }
    }
    fun dfs(n: Int): Int {
        this.ans = INF
        this._dfs(n, this.curState)
        return this.ans
    }
}


fun solveC(N: Int, A:Int, B:Int, C:Int, L:List<Int>): Int {
    PA = A; PB = B; PC = C
    val stDfs = StateDfs(N, L.toList(), 4)
    val res = stDfs.dfs(0)

    return res
}


fun main(args: Array<String>) {
    val (N,A,B,C) = readListInt()
    val L = Array<Int>(N){0}
    for(i in 0 until N) {
        L[i] = readInt()
    }

    val ans = solveC(N, A, B, C, L.toList())

    println(ans)
}
