#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  while (true) {
    int n; cin >> n;
    if (!n) break;
    V<string> s(n); for (auto&& e : s) cin >> e;
    reverse(begin(s), end(s));
    V< pair<int, int> > v;
    for (const auto& e : s) {
      if (isdigit(e.back())) {
        v.emplace_back(e.back() - '0', e.size());
      } else {
        if (e.back() == '+') {
          int s = 0;
          while (!v.empty() and v.back().second > (int)e.size()) {
            s += v.back().first;
            v.pop_back();
          }
          v.emplace_back(s, e.size());
        } else {
          int s = 1;
          while (!v.empty() and v.back().second > (int)e.size()) {
            s *= v.back().first;
            v.pop_back();
          }
          v.emplace_back(s, e.size());
        }
      }
    }
    cout << v.back().first << '\n';
  }
}
