#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;
int solve(vector<string> fi,int ind){
  if(fi.size()==1) return fi[0][ind]-'0';
  vector<int> sons;
  REP(i,fi.size()) if(fi[i].size()==ind+2) sons.push_back(i);
  sons.push_back(fi.size());
  bool mult=fi[0][ind]=='*';
  int ans;
  if(mult) ans=1;
  else ans=0;
  REP(i,sons.size()-1){
    int tmp=solve(vector<string>(fi.begin()+sons[i],fi.begin()+sons[i+1]),ind+1);;
    if(mult) ans*=tmp;
    else ans+=tmp;
  }
  return ans;


}
int main(void)
{
  for(;;){
    int n;
    cin >> n;
    if(!n) return 0;
    vector<string> fi(n);
    REP(i,n) cin >> fi[i];
    cout << solve(fi,0) << endl;
  }
}