#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

int n;
vector<string> s;

int dfs(int &i, int lev) {
    if (isdigit(s[i][lev])) {
        return s[i++][lev] - '0';
    } else if (s[i][lev] == '+') {
        ++i;
        int res = 0;
        while (i < n && s[i].size() == lev + 2) {
            res += dfs(i, lev + 1);
        }
        return res;
    } else {
        ++i;
        int res = 1;
        while (i < n && s[i].size() == lev + 2) {
            res *= dfs(i, lev + 1);
        }
        return res;
    }
}

void _main() {
    while (cin >> n, n) {
        s.resize(n);
        REP (i, n) cin >> s[i];
        int i = 0;
        cout << dfs(i, 0) << endl;
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}
