#include<bits/stdc++.h>
#define int long long
#define mod 998244353
using namespace std;
int dp[505][505];
int32_t main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin>>n;
pair<int,int> a[n];
for(int i=0;i<n;i++)
    {char x;
     cin>>x;
     if(x=='+'){cin>>a[i].first;a[i].second=i;}
     else{a[i]=make_pair(-1,-1);}
    }
int ans=0;
for(int ip=0;ip<n;ip++)
    {if(a[ip].first==-1){continue;}
     for(int i=0;i<=n;i++)
        {for(int j=0;j<=i+1;j++){dp[i][j]=0;}
        }
     dp[0][0]=1;
     int occurs=0;
     for(int i=1;i<=n;i++)
        {if(a[i-1]==a[ip])
            {dp[i][0]=0;
                for(int j=1;j<=i;j++)
                {dp[i][j]=dp[i-1][j-1];
                }
            occurs=1;
                continue;
            }
            for(int j=0;j<=i;j++)
            {if(a[i-1].first==-1)
                {dp[i][j]=dp[i-1][j];
                 if(j+1<=i-1){dp[i][j]+=dp[i-1][j+1];}
                 if(j==0){dp[i][j]+=dp[i-1][0];}
                 dp[i][j]%=mod;continue;
                }
             if(a[i-1]>a[ip]){dp[i][j]=2*dp[i-1][j];dp[i][j]%=mod;continue;}
             dp[i][j]=dp[i-1][j];
             if(j>=1){dp[i][j]+=dp[i-1][j-1];}
             dp[i][j]%=mod;
            }
        if(occurs){dp[i][0]=0;}
        }
    int z=a[ip].first;
    for(int i=1;i<=n;i++){ans+=(dp[n][i]*z);ans%=mod;}
    /*for(int i=0;i<=n;i++)
        {for(int j=0;j<=n;j++)
            {cout<<dp[i][j]<<" ";
            }
            cout<<"\n";
        }
    cout<<ans<<"\n";*/
    }
cout<<ans;
}
