$n, $a, $b, $c = gets.split.map(&:to_i)
$l = $n.times.map{ gets.to_i }
$min = 1000000007

def dfs(n, a, b, c, aa, bb, cc)
    if n == $n
        min = $min
        if aa > 0 && bb > 0 && cc > 0
            min = [$min, (a-$a).abs + (b-$b).abs + (c-$c).abs+10*([aa-1,0].max)+10*([bb-1,0].max)+10*([cc-1,0].max)].min
        end
        #if min == 120
        #    puts "#{a} #{b} #{c} #{aa} #{bb} #{cc}"
        #end
        return min
    end
    
    #puts $l[n]
    one = dfs(n+1, a + $l[n], b, c, aa+1,bb,cc)
    two = dfs(n+1, a, b + $l[n], c,aa,bb+1,cc)
    thr = dfs(n+1, a, b, c + $l[n],aa,bb,cc+1)
    fou = dfs(n+1, a, b, c,aa,bb,cc)
    
    return [one,two,thr,fou].min
end

puts dfs(0, 0, 0, 0, 0, 0, 0)
