/*
	Codeforces Round #729 (Div. 2)
	
	题解都没太看明白，我裂开
	原文链接：https://blog.csdn.net/jziwjxjd/article/details/118559087 
	
	2021.07.15	
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=998244353;
const int maxn=505;

ll n;
ll a[maxn]; 
ll dp[maxn][maxn];

void DP(){
	ll ans=0; 
	for(int i=1;i<=n;i++){//遍历数
		if(a[i]==-1)	continue;
		memset(dp,0,sizeof(dp));
		dp[0][0]=1ll; 
		for(int j=1;j<=n;j++){//前j个 
			for(int k=0;k<=j;k++){//小于a[i]的有k个
				dp[j][k]=(dp[j][k]+dp[j-1][k])%mod; 
				if(a[j]==-1){
					dp[j][k]=(dp[j][k]+dp[j-1][k+1])%mod;
					if(k==0&&j<i)	dp[j][k]=(dp[j][k]+dp[j-1][k])%mod;
				}else{
					if(a[i]==a[j]){
						if(i<j)	dp[j][k]=(dp[j][k]+dp[j-1][k])%mod;
						if(k&&i>j)	dp[j][k]=(dp[j][k]+dp[j-1][k-1])%mod;
					}
					if(k&&a[i]>a[j])	dp[j][k]=(dp[j][k]+dp[j-1][k-1])%mod;
					if(a[i]<a[j])	dp[j][k]=(dp[j][k]+dp[j-1][k])%mod;
				}
			}
		}
		for(int j=0;j<=n;j++)	ans=(ans+dp[n][j]*a[i]%mod)%mod;
	}
	printf("%lld\n",ans);
}

int main(){
	cin>>n;
	char c;
	ll ans=0;
	for(int i=1;i<=n;i++){
		getchar();
		scanf("%c",&c);
		if(c=='+')	scanf("%lld",&a[i]);
		else		a[i]=-1;
	}
	DP();
	return 0;
}
/*
4
-
+ 1
+ 2
-

15
+ 2432543
-
+ 4567886
+ 65638788
-
+ 578943
-
-
+ 62356680
-
+ 711111
-
+ 998244352
-
-
*/