#include<bits/stdc++.h>
#define re register
using namespace std;
typedef long long ll;


ll rd(){
	ll x = 0;
	char ch = getchar();
	while(ch < '0' || ch > '9') {
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return x;
}

const int MOD = 998244353;

void add(int &a,int b){
	a += b;
	if(a >= MOD) a -= MOD;
}

int dp[505][505];

int main(){
	char op[5];
	int n = rd();
	vector<int> a(n);
	for(int i = 0;i < n;i++){
		scanf("%s",op);
		if(op[0] == '+') a[i] = rd();
		else a[i] = -1;
	}
	int ans = 0;
	for(int i = 0;i < n;i++){
		if(a[i] != -1) {
			memset(dp,0,sizeof dp);
			dp[0][0] = 1;
			for(int j = 0;j < n;j++){
				for(int k = 0;k < n;k++){
					add(dp[j + 1][k],dp[j][k]);
					if(j != i) {
						if(a[j] >= 0) {
							bool ok = (a[j] < a [i]) || (a[j] == a[i] && i < j);
							add(dp[j + 1][k + ok],dp[j][k]);
						}
						else {
							if(k > 0) {
								add(dp[j + 1][k - 1],dp[j][k]);
							}	
							else if(j < i){
								add(dp[j + 1][k],dp[j][k]);
							}
						}
					}
				}
			}
			for(int k = 0;k <= n;k++)
				ans = (ans + (ll)dp[n][k] * a[i] % MOD) % MOD; 
		}
	}
	cout << ans;
}
