#include<cstdio>
#include<string>
#include<vector>
#include<iostream>
using namespace std;
typedef long long ll;

ll n, d[1000000], e[1000000]; // e: 0+ 1*
string s;

int main() {
  while (scanf("%lld", &n), n) {
    d[0] = 0, e[0] = 0;
    ll mx = 0;
    for (ll i = 0; i < n; i++) {
      cin >> s;
      ll sz = s.size()-1;
      while (mx != sz) {
        if (e[mx-1]) d[mx-1] *= d[mx];
        else d[mx-1] += d[mx];
        mx--;
      }
      if (s[sz] == '+') mx++, e[mx] = 0, d[mx] = 0;
      else if (s[sz] == '*') mx++, e[mx] = 1, d[mx] = 1;
      else {
        if (e[mx]) d[mx] *= s[sz] - '0';
        else d[mx] += s[sz] - '0';
      }
    }
    while (mx != 0) {
      if (e[mx-1]) d[mx-1] *= d[mx];
      else d[mx-1] += d[mx];
      mx--;
    }
    printf("%lld\n", d[0]);
  }
}

