#include <iostream>
#include <vector>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;

int n;
vector< pair<int, int> > input;

int dfs(int p) {
  int t = input[p].first + 1;
  char e = (char) input[p].second;
  int ans;

  if(e == '+') ans = 0;
  if(e == '*') ans = 1;
  if(e != '+' && e != '*') return e;

  for(int i = p + 1; input[i].first >= t && i < input.size(); i++) {
    if(input[i].first > t) continue;

    int v;
    if(input[i].second == '+' || input[i].second == '*') v = dfs(i);
    else v = input[i].second;

    if(e == '+') ans += v;
    if(e == '*') ans *= v;
  }

  return ans;
}

int main(void) {
  while(1) {
    cin >> n;
    if(n == 0) break;

    input.clear();
    REP(i, 0, n) {
      string line; cin >> line;
      int level = 0;
      for(; line[level] == '.'; level++);
      char c = line[level];
      input.push_back(pair<int, int>(level, c == '+' || c == '*' ? c : c - '0'));
    }

    cout << dfs(0) << endl;
  }

  return 0;
}