nums = []
5.times do |_i|
  nums << gets.chop.to_i
end

mod = nums.map{ |num| num % 10 }
mods = []
mod.each_with_index do |m, i|
    if m == 0
        mods[i] = 10
    else
        mods[i] = m
    end
end

min_i = mods.index(mods.min)

res = 0
nums.each_with_index do |n, i|
    if i == min_i
        res += n
    else
        res += n + (10 - mods[i])
    end
end

p res

