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

int main() {
  static auto add = [](int a, int b) { return a + b; };
  static auto mul = [](int a, int b) { return a * b; };
  int n;
  while (cin >> n, n) {
    vector<pair<function<int(int, int)>, int>> v;
    v.push_back(make_pair(add, 0));
    for (int i = 0; i < n; i++) {
      string s;
      cin >> s;
      int d = s.size() - 1;
      char c = *s.rbegin();
      while (d < v.size() - 1) {
        int r = v.back().second;
        v.pop_back();
        v.rbegin()->second = v.rbegin()->first(v.rbegin()->second, r);
      }
      if (c == '+') {
        v.push_back(make_pair(add, 0));
      } else if (c == '*') {
        v.push_back(make_pair(mul, 1));
      } else {
        v.rbegin()->second = v.rbegin()->first(v.rbegin()->second, c - '0');
      }
    }
    while (v.size() > 1) {
      int r = v.back().second;
      v.pop_back();
      v.rbegin()->second = v.rbegin()->first(v.rbegin()->second, r);
    }
    cout << v.front().second << endl;
  }
  return 0;
}

