#include <bits/stdc++.h>
using namespace std;

int n,l[1000],a[1000],b[1000],c[1000];
char s[1000][1000];
vector<int> v[1000];
int main(){
	scanf("%d",&n);
while(n){
	for(int i=0;i<n;i++){
		scanf(" %s",s[i]);
		l[i]=strlen(s[i])-1;
		if(s[i][l[i]]=='+')
			b[i]=1;
		else if(s[i][l[i]]=='*')
			b[i]=2;
		else{
			b[i]=0;
			a[i]=s[i][l[i]]-'0';
		}
	}
	l[n]=0;
	for(int i=0;i<=100;i++)
	v[i].clear();
	for(int i=0;i<n;i++){
		if(b[i]==0){
			if(l[i]==l[i+1])
				v[l[i]].push_back(a[i]);
			else{
				v[l[i]].push_back(a[i]);

				for(int j=l[i];j>l[i+1];j--){
					//for(auto k: v[j])	printf("%d ",k);printf("!!i%d\n",c[j]);
					int t=c[j]-1;
					for(auto k:v[j])
						if(c[j]==1)
							t+=k;
						else
							t*=k;
					//printf("%d %d\n",t,j);
					v[j-1].push_back(t);
					v[j].clear();
				}
			}
		}else{
			c[l[i]+1]=b[i];
		}
	}
	printf("%d\n",v[0][0]);
	scanf("%d",&n);
}
	return 0;
}