object Main extends App {

  import scala.io.StdIn._
  import scala.math._
  solve
  def solve: Unit = {
    val n = readLine.trim.toInt
    if (n == 0) return
    println(solveExpression(List.tabulate(n){_ ⇒ readLine.trim}))
    solve
  }
  def solveExpression(expression: List[String]): Long = {
    def solveDepth(expression: List[String], depth: Int, result: List[Long] = Nil): (List[Long], List[String]) = {
      expression match {
        case h::t if h.isDepthN(depth) ⇒
          h.asDepthN(depth) match{
            case n if n.isDigit ⇒ solveDepth(t, depth, n.asDigit::result)
            case o ⇒
              val (numbers, rest) = solveDepth(t, depth + 1)
              o match {
                case '+' ⇒ solveDepth(rest, depth, numbers.sum::result)
                case '*' ⇒ solveDepth(rest, depth, numbers.product::result)
                case _ ⇒ ???
              }
          }
        case _ ⇒ (result, expression)
      }
    }
    solveDepth(expression, 0)._1.head
  }
  implicit class Token(str: String){
    def isDepthN(n: Int): Boolean = if (n == 0) str(n) != '.'
    else str.indices.contains(n - 1) && str(n - 1) == '.' && str(n) != '.'
    def asDepthN(n: Int): Char = str(n)

  }

  @inline
  def lowerBound[T](array: Array[T], target: T)(implicit ord: Ordering[T]): Int = {
    var left = 0
    var right = array.length
    while (left < right){
      val mid = (left + right) / 2
      if (ord.compare(array(mid), target) < 0){
        left = mid + 1
      }else {
        right = mid
      }
    }
    right
  }
  @inline
  def upperBound[T](array: Array[T], target: T)(implicit ord: Ordering[T]): Int = {
    var left = 0
    var right = array.length
    while (left < right){
      val mid = (left + right) / 2
      if (ord.compare(array(mid), target) <= 0){
        left = mid + 1
      }else {
        right = mid
      }
    }
    right
  }
  implicit class Extension[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}
