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

vector<char> nest;
vector<int> dot;
int idx;

int solve(){
  if('0' <= nest[idx] and nest[idx] <= '9') return nest[idx++] - '0';
  int k = idx++, res = (nest[k] == '+' ? 0 : 1);
  while(dot[idx] == dot[k] + 1){
    if(nest[k] == '+') res += solve();
    if(nest[k] == '*') res *= solve();
  }
  return res;
}

int main(){
  int n;
  while(cin >> n, n){
    string str;
    nest.clear();
    dot.clear();
    for(int i = 0; i < n; i++){
      cin >> str;
      dot.push_back(str.size());
      nest.push_back(str[str.size() - 1]);
    }
    dot.push_back(0);
    idx = 0;
    cout << solve() << endl;
  }
  return 0;
}

