#include <bits/stdc++.h> 

using namespace std; 
#define ll long long
 
#define pii pair<int,int>
#define pll pair<ll,ll>
 
#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define vpi vector<pii>
#define vpl vector<pll>
#define pb push_back
#define all(v) v.begin(),v.end()
#define fast_io ios_base::sync_with_stdio(0),cin.tie(0);
 
 
template <class T>
void print(vector<T> a) {
	cout<<a[0];
    for(ll i = 1; i < a.size(); ++i) {
        cout <<' '<<a[i];
    }
    cout<<"\n";
}
 
int sum_vector(vi v){
	return accumulate(all(v),0);
}
 
void sort_vector(vi&v){
	sort(all(v));
}
 
void sort_comp(vi &v, bool func(int,int)){
	sort(all(v),func);
}
 

bool comp(array<ll,2> a, array<ll,2> b){
	return a[1]<b[1];
}
 
ll gcd(ll a, ll b){
	a=abs(a);
	b=abs(b);
	while(a){
		ll temp =a;
		a=b%a;
		b=temp;
	}
	return abs(b);
}
 
ll lcm(ll a, ll b){
	return (a*b)/gcd(a,b);
}
 
string binary(ll num){
	string ans="";
	do{
		ans=to_string(num%2)+ans;
		num/=2;
	}while(num);
	return ans;
}
 
const int mxn = 5e2+7;
const int d = 18;
const int mill = 1e6+3;
const ll mod = 998244353; 
 
ll pwr(ll num, ll p){
	ll res=1;
	while(p>0){
		if(p&1) res=(res*num)%mod;
		num=(num*num)%mod;
		p/=2;
	}
	return res;
}

ll inverse(ll num){
	return pwr(num,mod-2);
}


void solve(){
	int n;
	cin>>n;
	ll ans=0;
	vector<pair<char,ll>> v(n);
	for(int i=0;i<n;i++){
		cin>>v[i].first;
		if(v[i].first=='+'){
			cin>>v[i].second;
		}
		else{
			v[i].second=-1;	
		}
	}
	for(int i=0;i<n;i++){
		if(v[i].second==-1) continue;
		ll dp[mxn][mxn];
		for(int x=0;x<mxn;x++) for(int y=0;y<mxn;y++) dp[x][y]=0;
		dp[0][0]=1;
		for(int j=0;j<n;j++){
			for(int y=0;y<n;y++){
				if(v[j].second==-1){
					if(i>j || y>0) dp[j+1][max(0,y-1)]+=dp[j][y];
				}
				else{
					if((j<i && v[i]==v[j]) || v[i]>v[j]) dp[j+1][y+1]+=dp[j][y];
					else dp[j+1][y]+=dp[j][y];
				}
				if(i!=j) dp[j+1][y]+=dp[j][y];
					
				dp[j+1][max(0,y-1)]%=mod;
				dp[j+1][y]%=mod;
			}
		}
		for(int y=0;y<mxn;y++){
			ans+=dp[n][y]*v[i].second;
			ans%=mod;
		}
	}
	cout<<ans;
}

 
 
int main()
{
	fast_io
	int t=1;
	//cin>>t;
	
	for(int ii=1;ii<=t;ii++){
		solve();
	}
	
	
	return 0;
}