#include <bits/stdc++.h>
#define ll long long
#define dro long double
#define ii pair<int,int>
#define F first
#define S second
#define fr(i,l,n) for(int i=l; i<n; i++)
#define al(fu) (fu).begin(), (fu).end()
#define alr(fu) (fu).rbegin(), (fu).rend()
#define skoree ios::sync_with_stdio(0); cin.tie(0)
#define br cout<<"\n"
#define pr(c) cout<<c<<"\n"
#define pr2(c1,c2) cout<<c1<<' '<<c2<<"\n"
#define pr3(c1,c2,c3) cout<<c1<<' '<<c2<<' '<<c3<<"\n"
#define prv(a) {fr(qz,0,a.size()) cout<<a[qz]<<' '; br;}
#define prm(a,n) {fr(qz,0,n) cout<<a[qz]<<' '; br;}
#define prw(a,n,m) {fr(i,0,n) {fr(j,0,m) cout<<a[i][j]<<' '; br;}}
#define danet(b) cout<<(b?"YES":"NO")<<"\n"
#define Danet(b) cout<<(b?"Yes":"No")<<"\n"
using namespace std;
const int nh=101, m7=1000000007, m99=998244353;
const int ogo=m7,nhl=19,mh=nh; const double eps=1e-9;

int main(){
    skoree;
    int n; cin>>n;
    vector<int> a(n);
    fr(i,0,n){
        char qc; cin>>qc;
        if(qc=='+') cin>>a[i];
    }
    ll c=0;
    ll d[n+1][n];
    fr(h,0,n) if(a[h]){
        int x=a[h];
        memset(d,0,sizeof(d)); d[0][0]=1;
        fr(i,0,n) fr(j,0,n){
            d[i+1][j]=d[i][j];
            if(i==h) continue;
            if(!a[i]){
                if(j<n-1) d[i+1][j] = (d[i+1][j]+d[i][j+1])%m99;
                if(j==0 && i<h) d[i+1][j] = (d[i+1][j]+d[i][j])%m99;
            }
            else if(a[i]>x || a[i]==x&&i>h) d[i+1][j] = (d[i+1][j]+d[i][j])%m99;
            else if(j) d[i+1][j] = (d[i+1][j]+d[i][j-1])%m99;
        }
        c = (c+accumulate(d[n],d[n]+n,0LL)%m99*x%m99)%m99;
    }
    pr(c);
    return 0;
}

/*
*/
