#include <bits/stdc++.h>
using namespace std;

const int mux_n = 2000;

enum _operator{
    _plus,
    multiply,
    none
};

void En_route_culc(vector<_operator>& level_ope,vector<vector<long long int> >& level_num,int min_level, int max_level ){
    int now_level = max_level;
    while(min_level < now_level){
        if(level_ope[now_level-1] != none){
            long long int sum;
            if(level_ope[now_level-1] == _plus){
                sum = 0;
                for(int i=0; i<level_num[now_level].size(); i++){
                    sum += level_num[now_level][i];
                }
            }
            else if(level_ope[now_level-1] == multiply){
                sum = 1;
                for(int i=0; i<level_num[now_level].size(); i++){
                    sum *= level_num[now_level][i];
                }
            }
            if(now_level == 1) {
            }
            else{
                level_num[now_level-1].push_back(sum);
            }
        }
        now_level--;
    }
}

int main() {

    ofstream ofs("out.txt");

    while(1){

        int n;

        cin >> n;

        if(n==0) break;

        string input[n];

        vector<vector<long long int> > level_num;
        vector<_operator> level_ope;

        level_num.resize(mux_n);


        for(int i=0; i<mux_n; i++){
            level_ope.push_back(none);
        }

        int max_level = 0;

        for(int i=0; i<n; i++){
            cin >> input[i];
            for(int j=0; j<input[i].size(); j++){
                if(input[i][j] == '+'){
                    if(level_ope[j] != none){
                        En_route_culc(level_ope,level_num,j,max_level);
                        //level_num[j].push_back(tmpsum);
                        for(int k=max_level; j<k; k--) {
                            while (!level_num[k].empty()) {
                                level_num[k].pop_back();
                            }
                        }
                        max_level = j;
                        /*while(!level_num[j+1].empty()){
                            level_num[j+1].pop_back();
                        }*/
                    }
                    level_ope[j] = _plus;
                }
                else if(input[i][j] == '*'){
                    if(level_ope[j] != none){
                        En_route_culc(level_ope,level_num,j,max_level);
                        //level_num[j].push_back(tmpsum);
                        for(int k=max_level; j<k; k--) {
                            while (!level_num[k].empty()) {
                                level_num[k].pop_back();
                            }
                        }
                        max_level = j;
                    }
                    level_ope[j] = multiply;
                }
                else if(input[i][j] != '.'){
                    string string_now_input_num;
                    for(int k=j; k<input[i].size(); k++){
                        string_now_input_num.push_back(input[i][k]);
                    }
                    stringstream ss;
                    ss << string_now_input_num;
                    int input_num;
                    ss >> input_num;
                    level_num[j].push_back(input_num);
                }
                max_level = max(max_level,j);
            }
        }

        long long int ans = 0;
        int now_level = max_level;

        while(now_level){
            if(level_ope[now_level-1] != none){
                long long int sum;
                if(level_ope[now_level-1] == _plus){
                    sum = 0;
                    for(int i=0; i<level_num[now_level].size(); i++){
                        sum += level_num[now_level][i];
                    }
                }
                else if(level_ope[now_level-1] == multiply){
                    sum = 1;
                    for(int i=0; i<level_num[now_level].size(); i++){
                        sum *= level_num[now_level][i];
                    }
                }
                if(now_level == 1) {
                    ans = sum;
                }
                else{
                    level_num[now_level-1].push_back(sum);
                }
            }
            now_level--;
        }

        if(n == 1){
            ans = level_num[0][0];
        }

        cout << ans << endl;

    }

    return 0;
}


Measured memory_bytes: 3236