#include<bits/stdc++.h>
using namespace std;
#define fa(i,a,b) for(int i=a;i<b;i++)
#define rfa(i,a,b) for(int i=b-1;i>=a;i--)
#define int long long
#define ld long double
#define vec vector<int>
#define vecv vector<vec>
#define pb push_back
#define all(a) a.begin(),a.end()
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define endl '\n'
#define show(a) for(auto el:a)cout<<el<<" "
#define pr pair<int,int>
#define x first
#define y second
const int M=998244353;
const int INF=LLONG_MAX/2;
const int N=2e5+1;

signed main()
{ios_base::sync_with_stdio(0);
 cin.tie(0);
 cout.tie(0);
 //int t;cin>>t;while(t--)
 {
 	int n;
 	cin>>n;
 	vec a(n+1);
 	char c;
 	fa(i,1,n+1)
 	{
 		cin>>c;
 		if(c=='+')cin>>a[i];
	}
	int ans=0;
	fa(k,1,n+1)if(a[k])
	{
		vecv dp(n+2,vec(n+2));
		dp[0][0]=1;
		fa(i,1,n+1)
			fa(j,0,i+1)
			{
				if(a[i]==0)
				{
					if(i<=k||j>0)dp[i][max(j-1,0ll)]+=dp[i-1][j],dp[i][max(j-1,0ll)]%=M;
				}
				else 
				{
					if(a[i]<a[k]||a[i]==a[k]&&i<k)dp[i][j+1]+=dp[i-1][j],dp[i][j+1]%=M;
					else dp[i][j]+=dp[i-1][j],dp[i][j]%=M;	
				}
				if(i!=k)
				{
					dp[i][j]+=dp[i-1][j],dp[i][j]%=M;
				}
			}
		fa(i,0,n+1)
		ans+=dp[n][i]*a[k],ans%=M;
	}
	cout<<ans<<endl;
 }
 return 0;}


