#include <bits/stdc++.h>
 
using namespace std;
 
// typedef
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
 
// container util
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for (typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
// repetition
#define FOR(i,m,n) for (ll (i) = ((ll) m); (i) < ((ll) n); ++(i))
#define RFOR(i,m,n) for (ll (i) = ((ll) (m)-1); (i) >= ((ll) n); --(i))
#define REP(i,n) FOR(i,0,n)
 
// i/o
#define TFOUT(b,t,f) cout << ((b)? (t) : (f)) << endl
 
// clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
// debug
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl


struct Cell {
    bool is_num;
    char sym;
    int num;
    vector<Cell> cells;
};

string expr(int n) {
    string expr;
    string s; cin >> s;
    expr.push_back(s[0]);
    int depth = 1;
    REP(i, n-1) {
        string s; cin >> s;
        int len = s.length();
        if (len > depth) {
            REP(i, len - depth) {
                expr.push_back('(');
            }
        } else if (len < depth) {
            REP(i, depth - len) {
                expr.push_back(')');
            }
        }
        expr.push_back(s[len-1]);
        depth = len;
    }
    REP(i, depth-1) {
        expr.push_back(')');
    }
    depth = 1;
    return expr;
}

Cell tree_(const string& expr, int& pos) {
    Cell result;
    if (expr[pos] == '+' || expr[pos] == '*') {
        result.is_num = false;
        result.sym = expr[pos];
        pos++;
        pos++;
        while (true) {
            result.cells.push_back(tree_(expr, pos));
            if (expr[pos] == ')') break;
        }
        pos++;
    } else {
        result.is_num = true;
        result.num = expr[pos] - '0';
        pos++;
    }
    return result;
}

Cell tree(const string& expr) {
    int pos = 0;
    return tree_(expr, pos);
}

Cell eval(Cell& cell) {
    for (int i = 0; i < cell.cells.size(); i++) {
        cell.cells[i] = eval(cell.cells[i]);
    }
    if (cell.is_num) return cell;
    if (cell.sym == '+') {
        int num = 0;
        for (int i = 0; i < cell.cells.size(); i++) {
            num += cell.cells[i].num;
        }
        cell.is_num = true;
        cell.num = num;
        return cell;
    } else {
        int num = 1;
        for (int i = 0; i < cell.cells.size(); i++) {
            num *= cell.cells[i].num;
        }
        cell.is_num = true;
        cell.num = num;
        return cell;
    }
}

void solve(int n) {
    string e = expr(n);
    Cell c = tree(e);
    c = eval(c);
    cout << c.num << endl;;
}
int main() {
    while(true) {
        int n; cin >> n;
        if (n == 0) break;
        solve(n);
    }
    return 0;
}

/*
num  ::= [0-9]
op   ::= + | *
expr ::= num | op (expr expr)
*/


Measured memory_bytes: 3120