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

int N;
vector<string> input;
int level;
char c;
int idx;
bool next(){
	idx++;
	if(idx <= N){
		string str;
		cin >> str;
		level = str.length() - 1;
		c = str[str.length() - 1];
		return true;
	}
	return false;
}

int recur(int l){
	if(c == '+'){
		int val = 0;
		next();
		while(idx <= N){
			if(l > level){
				break;
			}else if(c == '+' || c == '*'){
				val += recur(l + 1);
			}else{
				val = val + (c - '0');
				next();
			}
		}
		return val;

	}else if(c == '*'){
		int val = 1;
		next();
		while(idx <= N){
			if(l > level){
				break;
			}else if(c == '+' || c == '*'){
				val *= recur(l + 1);
			}else{
				val = val * (c - '0');
				next();
			}	
		}
		return val;

	}else{
		return c - '0';
	}
}

int main(){
	while(cin >> N, N){
		idx = 0;
		next();
		cout << recur(1) << endl;
	}
}