// Aizu 1602: ICPC Calculator
// 2017.9.21 bal4u@uu

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

char e[20][50]; int n;

int calc(int lv, int *k)
{
	int i, x, y, op, f, m;
	char *p;
	
	m = *k;
	p = e[m]; for (i = 0; *p && i < lv; i++) *p++;
	if (isdigit(*p)) { *k = m+1; return *p - '0'; }
	if (!*p) return 0;  // Panic 
	op = *p, lv++, m++; if (op == '+') x = 0; else x = 1;
	while (m < n) {
		f = 0;
		p = e[m]; for (i = 0; *p && i < lv; i++) if (*p++ != '.') break;
		if (i < lv) break;
		if (isdigit(*p)) y = *p - '0', f = 1;
		else             y = calc(lv, &m);
		if (op == '+') x += y; else x *= y;
		if (f) m++;
	}
	*k = m;
	return x;
}

int main()
{
	int i;
	while (scanf("%d", &n) && n) {
		for (i = 0; i < n; i++) scanf("%s", e[i]);
		i = 0; printf("%d\n", calc(0, &i));
	}
	return 0;
}