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

int main()
{
	int n;
	string s;
	while (cin >> n, n) {
		vector<int> st, ope, cnt;
		cnt.push_back(0);
		int tmp = 0;
		while (n--) {
			cin >> s;
			for (int i = 0; i < tmp - (int)s.size(); i++) {
				int val = ope.back() ? 0 : 1;
				while (cnt.back()--) {
					int sb = st.back();
					val = ope.back() ? val + sb : val * sb;
					st.pop_back();
				}
				st.push_back(val);
				cnt.pop_back();
				ope.pop_back();
			}
			if (isdigit(s.back())) {
				st.push_back(s.back() - '0');
				cnt.back()++;
			}
			else {
				cnt.back()++;
				ope.push_back(s.back() == '+' ? 1 : 0);
				cnt.push_back(0);
			}
			tmp = s.size();
		}
		while (!ope.empty()) {
			int val = ope.back() ? 0 : 1;
			while (cnt.back()--) {
				int sb = st.back();
				val = ope.back() ? val + sb : val * sb;
				st.pop_back();
			}
			st.push_back(val);
			cnt.pop_back();
			ope.pop_back();
		}
		cout << st.back() << endl;
	}
	return 0;
}