#include<bits/stdc++.h>
#define N 100
using namespace std;
string s[N];
int n,y;

int dfs(int x){
  int res;
  if('0'<=s[y][x]&&s[y][x]<='9')
    return s[y][x]-'0';
  if(s[y][x]=='+'){
    res=0;
    while(x+2<=s[y+1].size())
      y++,res+=dfs(x+1);
  }
  if(s[y][x]=='*'){
    res=1;
    while(x+2<=s[y+1].size())
      y++,res*=dfs(x+1);
  }
  return res;
}

int main(){
  while(1){
    cin>>n;
    if(!n)break;
    for(int i=0;i<N;i++)s[i]="";
    for(int i=0;i<n;i++)
      cin>>s[i];
    y=0;
    cout<<dfs(0)<<endl;
  }
  return 0;
}