#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

string s[100];
int cur;
int dfs(int d){
    int ret;
    if(isdigit(s[cur][d])) return s[cur++][d]-'0';
    else{
        if(s[cur][d]=='+'){
            ret=0;
            ++cur;
            while(s[cur].size()==d+2)ret+=dfs(d+1);
        }
        else if(s[cur][d]=='*'){
            ret=1;
            ++cur;
            while(s[cur].size()==d+2)ret*=dfs(d+1);
        }
    }
    return ret;
}
int main(){
    int n;
    while(cin>>n,n){
        cur=0;
        rep(i,100) s[i].clear();
        rep(i,n) cin>>s[i];
        cout<<dfs(0)<<endl;
    }
    return 0;
}
