#include<bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define swap(a,b) (a^=b^=a^=b)
#define int long long
#define ull unsigned long long int
#define uint unsigned int
#define format(a) memset(a,0,sizeof(a))
#define rep(x,y,z) for(int x=y;x<=z;x++)
#define dec(x,y,z) for(int x=y;x>=z;x--)
#define mst(x) memset(x,0,sizeof(x))
const int maxn=505;
inline int read()
{
    int ans=0;
    char last=' ',ch=getchar();
    while(ch<'0'|ch>'9')last=ch,ch=getchar();
    while(ch>='0' && ch<='9')ans=ans*10+ch-'0',ch=getchar();
    if(last=='-')ans=-ans;
    return ans;
}
const int mod=998244353;
string op[maxn];
int a[maxn],dp[maxn],two[maxn];
signed main()
{
    int n=read();two[0]=1;
    rep(i,1,n)
    {
        two[i]=two[i-1]*2%mod;
        cin>>op[i];
        if(op[i]=="+")cin>>a[i];
    }
    int ans=0;
    rep(k,1,n)if(op[k]=="+")
    {
        format(dp);dp[0]=1;
        int cnt=0;
        rep(i,1,n)
        {
            if(i<=k)cnt+=(a[i]>a[k]);
            else cnt+=(a[i]>=a[k]);
        }
        rep(i,1,n)
        {
            if(i==k)continue;
            if((i<k&&a[i]>a[k])||(i>k&&a[i]>=a[k]))continue;
            if(op[i]=="-")
            {
                if(i<k)(dp[0]*=2)%=mod;
                rep(p,0,n-1)(dp[p]+=dp[p+1])%=mod;
            }
            else
            {
                dec(p,n-1,1)(dp[p]+=dp[p-1])%=mod;
            }
        }
        rep(i,0,n-1)(ans+=two[cnt]*dp[i]%mod*a[k])%=mod;
    }
    cout<<ans<<"\n";
    return 0;
}

