#include <stdio.h>
#include <string.h>
#include <ctype.h>

int i, n, val[500], depth[500];

int func(){
	int ans, now;

	if(isdigit(val[i])){
		return val[i++] - '0';
	}

	now = i++;
	ans = 1;
	if(val[now] == '+'){
		while(depth[now] == depth[i]-1){
			ans += func();
		}
		ans--;
	} else{
		while(depth[now] == depth[i]-1){
			ans *= func();
		}
	}

	return ans;
}



int main(void){
	int  ans;
	char tmp[500];

	while(1){
		scanf("%d", &n);
		if(n == 0) break;
		for(int i=0; i<n; i++){
			scanf("%s", tmp);
			depth[i] = strlen(tmp)-1;
			val[i] = tmp[depth[i]];
		}

		i = 0;
		ans = func();
		printf("%d\n", ans);
	}//endwhile
	
	return 0;
}
