#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)

int main()
{
    while (true)
    {
    	int n;
    	cin >> n;
    	if (n == 0) break;
    	string s;
    	int ans = 0;
    	stack<pair<char, int>> operate;
    	operate.push(make_pair('+', 0));
    	for (int i = 0;i < n;++ i) {
    		cin >> s;
    		while (operate.size() > s.size()) {
    			int tmp = operate.top().second;
    			operate.pop();
    			if (operate.top().first == '+') operate.top().second += tmp;
    			else operate.top().second *= tmp;
    		}
    		if ('0' <= s[s.size() - 1] && s[s.size() - 1] <= '9') {
    			if (operate.top().first == '+') operate.top().second += s[s.size() - 1] - '0';
    			else operate.top().second *= s[s.size() - 1] - '0';
    		} else if (s[s.size() - 1] == '+') operate.push(make_pair('+', 0));
    		else operate.push(make_pair('*', 1));
    	}
    	while (operate.size() > 1) {
			int tmp = operate.top().second;
			operate.pop();
			if (operate.top().first == '+') operate.top().second += tmp;
			else operate.top().second *= tmp;
    	}
    	cout << operate.top().second << endl;
    }
    return 0;
}
