#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=l;i<r;i++)

ll n,pos;
char s[20][20];

ll f(){
	ll len=strlen(s[pos]);
	char c=s[pos][len-1];
	if('0'<=c&&c<='9')return c-'0';
	ll ans=(c=='+'?0:1);
	while(strlen(s[pos+1])>len){
		pos++;
		ll temp=f();
		ans=(c=='+'?ans+temp:ans*temp);
	}
	return ans;
}

int main(){
	while(scanf("%lld",&n),n){
		rep(i,0,n)scanf(" %s",s[i]);
		s[n][0]=0;
		pos=0;
		printf("%lld\n",f());
	}
}
