while true
    n = gets.to_i
    break if n == 0

    lines = []
    n.times{
        line = gets.chomp
        lines << [line.count('.'), line[-1]]
    }

    stack = []
    (n - 1).downto(0){|i|
        level, number = lines[i]
        case number
        when "+"
            sum = 0
            until stack.empty? || stack[-1][0] != level + 1
                l, x = stack.pop
                sum += x
            end
            stack << [level, sum]
        when "*"
            product = 1
            until stack.empty? || stack[-1][0] != level + 1
                l, x = stack.pop
                product *= x
            end
            stack << [level, product]
        else
            stack << [level, number.to_i]
        end
    }
    puts stack[0][1]
end

