#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

int get_level(string s){
  int res = 0;
  REP(i,s.length()){
    if(s[i] == '.') res++;
  }
  return res;
}

bool is_ope(string s){
  REP(i,s.length()){
    if(s[i] == '+' || s[i] == '*') return true;
  }
  return false;
}

int get_num(string s){
  string tmp;
  REP(i,s.length()){
    if(s[i] != '.'){
      tmp = s.substr(i,s.length()-i);
      break;
    }
  }
  return stoi(tmp);
}

string get_ope(string s){
  return s.substr(s.length()-1,1);
}

int main(){

  while(true){
    int n;
    cin >> n;

    if(n == 0) break;

    if(n == 1){
      int tmp;
      cin >> tmp;
      cout << tmp << endl; 
      continue;
    }

    vector<string> s(n);
    REP(i,n){
      cin >> s[i];
    }

    stack<string> st_ope;
    vector<vector<int>> v(100);

    int level = 0;
    int ans = 0;
    REP(i,n){
      if(!is_ope(s[i])){
        while(level != get_level(s[i])){
              int sum = 0;
              string tp = st_ope.top();
              st_ope.pop();
              if(tp == "+"){
                REPI(itr,v[level]){
                  sum += *itr;
                }
              }else{
                sum = 1;
                REPI(itr, v[level]){
                  sum *= *itr;
                }
              }
              v[level].clear();
              level--;
              v[level].pb(sum);
       
        }
        int num = get_num(s[i]);
        v[level].pb(num);
      }else{
        if(is_ope(s[i])){
          if(level == get_level(s[i])){
            st_ope.push(get_ope(s[i]));
            level++;
            continue;
          }else{
            while(level != get_level(s[i])){
              int sum = 0;
              string tp = st_ope.top();
              st_ope.pop();
              if(tp == "+"){
                REPI(itr,v[level]){
                  sum += *itr;
                }
              }else{
                sum = 1;
                REPI(itr, v[level]){
                  sum *= *itr;
                }
              }
              v[level].clear();
              level--;
              v[level].pb(sum);
            }
            st_ope.push(get_ope(s[i]));
            level++;
          }
        }
      }

      if(i == n-1){
        while(level != 1){
          int sum = 0;
          string tp = st_ope.top();
          st_ope.pop();
          if(tp == "+"){
            REPI(itr,v[level]){
              sum += *itr;
            }
          }else{
            sum = 1;
            REPI(itr, v[level]){
              sum *= *itr;
            }
          }
          level--;
          v[level].pb(sum);
        }

        string tp = st_ope.top();
        st_ope.pop();
        if(tp == "+"){
          REPI(itr,v[level]){
            ans += *itr;
          }
        }else{
          ans = 1;
          REPI(itr, v[level]){
            ans *= *itr;
          }
        }
      }
    }


    cout << ans << endl;
  }
  return 0;
}




Measured memory_bytes: 3232