#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<n;i++)
#define REP1(i,n) for(long long i=1;i<=n;i++)
#define REP2D(i,j,h,w) for(long long i=0;i<h;i++) for(long long j=0;j<w;j++)
#define REP2D1(i,j,h,w) for(long long i=1;i<=h;i++) for(long long j=1;j<=w;j++)
#define PER(i,n) for(long long i=((n)-1);i>=0;i--)
#define PER1(i,n) for(long long i=(n);i>0;i--)
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define FORE(i,a,b) for(long long i=(a);i<=(b);i++)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();++ite)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define YNPRT(b) cout<<((b)?"Yes":"No")<<endl
#define REV(arr) reverse(ALL(arr))
#define PRT(a) cout<<a<<endl;
#define PRTLST(arr,num) REP(_i,num) cout<<_i<<" - "<<arr[_i]<<endl;
#define PRTLST2(arr2,d1,d2) REP(_i,d1) REP(_j,d2) cout<<_i<<","<<_j<<" : "<<arr2[_i][_j]<<endl;
#define PRTLST2D(arr2,d1,d2) do{cout<<"L\t";REP(_i,d2) cout<<_i<<"\t"; cout<<endl; REP(_i,d1){cout<<_i<<"\t";REP(_j,d2){cout<<arr2[_i][_j]<<"\t";}cout<<endl;}}while(0);
#define fst first
#define scd second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};

//---------------------
#define MAXN 100000
//---------------------

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {ITE(v) os << *ite << " ";return os;}

typedef ll (*oprfunc)(ll a,ll b);

struct Dataopr{
    Dataopr(ll l,oprfunc f,ll n){
        level=l;func=f;num=n;
    }
    ll level=-1;
    oprfunc func=nullptr;
    ll num=-1;
};

ll n,ret;
vector<string> data;
vector<Dataopr> oprdata;
stack<Dataopr> oprstack;


ll getlevel(const string& target){
    ll ret=0;
    ITE(target){
        if(*ite!='.') break;
        ret++;
    }
    return ret;
}

ll plusfunc(ll a,ll b){return a+b;}
ll multfunc(ll a,ll b){return a*b;}

oprfunc getopr(const string& target){
    ITE(target){
        if(*ite!='.') {
            if(*ite=='+') return plusfunc;
            if(*ite=='*') return multfunc;
            return nullptr;
        }
    }
    return nullptr;
}

ll getnum(const string& target){
    ITE(target){
        if(*ite!='.') {
            return *ite-'0';
        }
    }
    return -1;
}


bool init(){
    // Initializing
    data.clear();
    oprdata.clear();
    while(!oprstack.empty()) oprstack.pop();
    // Assignment
    cin>>n;
    if(n<=0) return false;
    REP(i,n){
        string curs;
        cin>>curs;
        data.push_back(curs);
    }

    ITE(data){
        oprdata.push_back(Dataopr(getlevel(*ite),getopr(*ite),getnum(*ite)));
    }
    oprdata.push_back(Dataopr(0,nullptr,-1));
    return true;
}

void subsolve(ll targetlevel){
   if(oprstack.empty()) return;
    Dataopr curdata=oprstack.top();
    vector<ll> numlist;
    while(curdata.level>=targetlevel){
        oprstack.pop();
        if(curdata.func){
            ll curret=(curdata.func==plusfunc)?0:1;
            REP(i,numlist.size()){
                curret=curdata.func(curret,numlist[i]);
            }
            numlist.clear();
            if(oprstack.size()) oprstack.push(Dataopr(oprstack.top().level,nullptr,curret));
            else {oprstack.push(Dataopr(0,nullptr,curret));return;}
            //cout<<curdata.level<<" "<<targetlevel<<endl;
            if(curdata.level==targetlevel) return;
        }else numlist.push_back(curdata.num);
        curdata=oprstack.top();
    }
}

void solve(){
    ll lastlevel=0;
    if(oprdata.size()==1) {ret=oprdata[0].num; return ;}
    //if(oprdata[0].func==plusfunc) ret=0; else ret=1;

    ITE(oprdata){
        if(ite->level<lastlevel){
            subsolve(ite->level);
        }
        lastlevel=ite->level;
        if(ite->func){
            oprstack.push(*ite);
            continue;
        }
        oprstack.push(*ite);
    }
    Dataopr last(0,nullptr,0);
    //subsolve(curlevel,last);
    oprstack.pop();
    ret=oprstack.top().num;
}

int main(){
    while(init()){
        solve();
        cout<<ret<<endl;
    }
    return 0;
}


Measured memory_bytes: 3152