local n = io.read("n")
local c = io.read("n")
local b = io.read("n")
local a = io.read("n")
function pay(x,y,z)
    return math.abs(x-a)+math.abs(y-b)+math.abs(z-c)
end
local bamboos = {}
function dfs(cur,a,b,c)
    if cur == #bamboos+1 then
        return math.min(a,b,c) > 0 and pay(a,b,c) - 30 or math.huge
    end
    local vcur = bamboos[cur]
    local toa = 10 + dfs(cur+1, a+vcur, b, c)
    local tob = 10 + dfs(cur+1, a, b+vcur, c)
    local toc = 10 + dfs(cur+1, a, b, c+vcur)
    local skip = dfs(cur+1, a, b, c)
    return math.min(toa, tob, toc, skip)
end

for i=1,n do
    bamboos[i] = io.read("n")
end
print(dfs(1,0,0,0))