#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
string s[100];
int N;
int rec(int& idx, int dep){
  if(isdigit(s[idx][dep])) return s[idx++][dep]-'0';
  else if(s[idx++][dep]=='+'){
    int ret = 0;
    while(s[idx].length()==dep+2) ret += rec(idx, dep+1);
    return ret;
  }
  else {
    int ret = 1;
    while(s[idx].length()==dep+2) ret *= rec(idx, dep+1);
    return ret;
  }
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  while(cin>>N&&N){
    FOR(i,0,N){
      cin>>s[i];
    }
    s[N]="";
    int idx = 0;
    cout<<rec(idx,0)<<endl;
  }
}
