#include<iostream>
#include<cstring>
using namespace std;
const int mod=998244353;
const int N=510;
int a[N];
long long  dp[N][N];
 int n;
 void solve(int p)
 {
    memset(dp,0,sizeof dp);
    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)   continue; 
            if(a[i]==-1)
            {
                dp[i][j]=(dp[i-1][j]+dp[i-1][j+1])%mod;
                if(j==0)
                dp[i][j]=(dp[i][j]+dp[i-1][0])%mod;
            }
            else {
                if(a[i]>a[p])
                {
                    dp[i][j]=(dp[i-1][j]+dp[i-1][j])%mod;
                }
                else if(a[i]<a[p])
                {
                    dp[i][j]=(dp[i-1][j]);
                    if(j)
                        dp[i][j]=(dp[i][j]+dp[i-1][j-1])%mod;
                }
                else
                {
                    if(i<p)
                    {

                        dp[i][j]=(dp[i-1][j])%mod;
                        if(j)
                        dp[i][j]=(dp[i][j]+dp[i-1][j-1])%mod;
                    }
                    else
                        dp[i][j]=(2*dp[i-1][j])%mod;
                }
            }
        }
    }
 }
int main()
{
   
    cin >> n;
    for(int i=1;i<=n;i++)
    {
        string s;
        cin >> s;
        if(s=="-")
            a[i]=-1;
        else
        {
            cin >> a[i];
        }
    }

    int res=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]>0)
        {
            solve(i);
        for(int j=1;j<=n;j++)
            res=(1ll*res+1ll*dp[n][j]*a[i]%mod)%mod;
        }
    }
    cout<<res<<endl;
    return 0;
}