N, A, B, C = gets.split(' ').map(&:to_i)
L = N.times.map { gets.to_i }

def f(cur, a, b, c)
  if cur == N
    return [a,b,c].min > 0 ? (a - A).abs + (b - B).abs + (c - C).abs - 30 : Float::INFINITY
  else
    mp1 = f(cur + 1, a, b, c)
    mp2 = f(cur + 1, a + L[cur], b, c) + 10
    mp3 = f(cur + 1, a, b + L[cur], c) + 10
    mp4 = f(cur + 1, a, b, c + L[cur]) + 10

    return [mp1, mp2, mp3, mp4].min
  end
end

puts f(0, 0, 0, 0)
