#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define repb(i, n) for(int i = n;i >= 0;i--)
#define reps(i, m, n) for(int i = m;i < n;i++)
#define repsb(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long ll;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
using namespace std;
string s[100];
int cal(int &index,int d){

  if(isdigit(s[index][d]))  return(s[index++][d]-'0');

  else if(s[index++][d]=='+'){
    int t=0;
    while ((int)s[index].size()>d+1){
      t+=cal(index,d+1);
    }
    return t;
  }
  else{
    int t=1;
    while ((int)s[index].size()>d+1) {
      t*=cal(index,d+1);
    }
    return t;
  }

  }
int main(int argc, char const *argv[]) {
  int n;
  	while(1){
  		cin>>n;
  		if(n==0)	break;
  		rep(i,n){
  			cin>>s[i];
  		}
      s[n]="";
      int index=0;
      cout<<cal(index,0)<<endl;
    }

  return 0;
}

