#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(true) {
        int n;
        cin >> n;
        if(n == 0) break;
        string S[100];
        for(int i = 1; i <= n; i++) cin >> S[i];
        vector<int> query[100];
        for(int i = n; i >= 1; i--) {
            int depth = S[i].size() - 1;
            if(S[i].back() <= '9' && S[i].back() >= '0') {
                query[depth].push_back((int)(S[i].back() - '0'));
                continue;
            }
            if(S[i].back() == '*') {
                int now = 1;
                for(int j = 0; j < query[depth+1].size(); j++) {
                    now *= query[depth+1][j];
                }
                query[depth].push_back(now);
                query[depth+1].clear();
            }
            if(S[i].back() == '+') {
                int now = 0;
                for(int j = 0; j < query[depth+1].size(); j++) {
                    now += query[depth+1][j];
                }
                query[depth].push_back(now);
                query[depth+1].clear();
            }
        }
        cout << query[0][0] << endl;
    }
    return 0;
}
