#include<iostream>
#include<cstring>
using namespace std;
#define int long long
const int N=510;
const int mod=998244353;

long long dp[N][N];//考虑前i个，有j个小于等于x的方案书
long long a[N];
int n;
void solve(int p)
{
    dp[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        if(i==p)
        {
            for(int j=1;j<=i;j++)
            {
                dp[i][j]=dp[i-1][j-1];
            }
                continue;
        }

        for(int j=0;j<=i;j++)
        {
            if(i>p && j==0) continue;
            dp[i][j]=dp[i-1][j];
            if(a[i]==-1)
            {
                dp[i][j]=(dp[i][j]+dp[i-1][j+1])%mod;
                if(j==0)    dp[i][0]=(dp[i][0]+dp[i-1][0])%mod;
            }
            else if(a[i]<=a[p])
            {
                if(i<p && j || a[i]<a[p] && j)
                dp[i][j]=(dp[i][j]+dp[i-1][j-1])%mod;
                if(i>p && a[i]==a[p])dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
            } else if(a[i]>a[p]){
                dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
            }
        }
    }
}
signed main()
{
    cin >> n;
    for(int i=1;i<=n;i++)
    {
        string s;
        cin >> s;
        if(s=="-")
            a[i]=-1;
        else
        {
            cin >> a[i];
        }
    }
//    for(int i=1;i<=n;i++)
//        cout<<a[i]<<" ";
//    cout<<endl;
    long long res=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]>0)
        {
            memset(dp,0,sizeof dp);
            solve(i);
            for(int j=1;j<=n;j++)
                res=(res+1ll*dp[n][j]*a[i]%mod)%mod;
        }
    }
    cout<<res<<endl;
    return 0;
}