local mfl, mce = math.floor, math.ceil
local bls, brs = bit.lshift, bit.rshift
local n = io.read("*n")
local a, b, c = io.read("*n", "*n", "*n")
local t = {}
for i = 1, n do
  t[i] = io.read("*n")
end
local tot = bls(1, 2 * n)
local ret = false
local mab = math.abs
for i = 0, tot - 1 do
  local ta, tb, tc = 0, 0, 0
  local ca, cb, cc = 0, 0, 0
  for j = 1, n do
    if i % 4 == 1 then
      ta = ta + t[j]
      ca = ca + 1
    elseif i % 4 == 2 then
      tb = tb + t[j]
      cb = cb + 1
    elseif i % 4 == 3 then
      tc = tc + t[j]
      cc = cc + 1
    end
    i = brs(i, 2)
  end
  if 0 < ca * cb * cc then
    local v = mab(ta - a) + mab(tb - b) + mab(tc - c)
    v = v + (ca + cb + cc - 3) * 10
    if not ret then ret = v
    elseif v < ret then ret = v
    end
  end
end
print(ret)
