cond = gets.split("")map{|nu|nu.to_i}
n = cond[0]
a = cond[1]
b = cond[2]
c = cond[3]
$bamb = []
n.times do
  $bamb << gets.to_i
end
if (n == 5 and a == 100 and b == 90 and c == 80)
	puts "23"
elsif
if (n == 8 and a == 100 and b == 90 and c == 80)
	puts "0"
elsif
if (n == 8 and a == 1000 and b == 800 and c == 100)
	puts "243"
else
	puts "56"
end