n = gets.to_i
price = [600,800,1000,1200,1400,1600]
until n == 0
all_cost = 0
n.times do
    x = gets.split(" ").map{|k| k.to_i }
    size = x[0] + x[1] + x[2]
    weight = x[3]
    cost1 = 0
    cost2 = 0
    qq = 0
    if size <= 60
        cost1 = price[0]
    elsif size <= 80
        cost1 = price[1]
    elsif size <= 100
        cost1 = price[2]
    elsif size <= 120
        cost1 = price[3]
    elsif size <= 140
        cost1 = price[4]
    elsif size <= 160
        cost1 = price[5]
    elsif size > 160
        qq = 1
    end

    if weight <= 2
        cost2 = price[0]
    elsif weight <= 5
        cost2 = price[1]
    elsif weight <= 10
        cost2 = price[2]
    elsif weight <= 15
        cost2 = price[3]
    elsif weight <= 20
        cost2 = price[4]
    elsif weight <= 25
        cost2 = price[5]
    elsif weight > 25
        qq = 1
    end
    if qq == 1
        all_cost += 0
    else
        if cost1 <= cost2
            all_cost += cost2
        else
            all_cost += cost1
        end
    end

end
puts all_cost
n = gets.to_i
end
