#include <bits/stdc++.h>
using namespace std;



const int MAXN = 3e5 + 5;

typedef long long ll;

#define endll "\n"
#define all(v) v.begin(),v.end()
#define min(a,b) a<b?a:b
#define max(a,b) a>b?a:b
#define deb(s) cout<<#s<<" :: "<<s<<endll

ll __gcd(ll x,ll y){	return y?__gcd(y,x%y):x;}
ll lcm(ll a,ll b){	return a/__gcd(a,b)*b;}

// Priority Queue
//f you

const ll mod = 998244353;
// ll mod;


 
ll n, m, q, k, l, r, x, y, z;
const ll template_array_size = 1e6 + 16614;
ll a[template_array_size];
ll b[template_array_size];
ll c[template_array_size];
string s, t;

ll dp[505][505];
inline void add(ll& a, ll b) {
	a += b;
	if (a >= mod) a -= mod;
}

void solve() {
	cin >> n;
	for (ll i = 0; i < n; i++) {
		char c;
		cin >> c;
		if (c == '+') cin >> a[i];
		else a[i] = -1;
	}
	
	ll ans = 0;
	for (ll i = 0; i < n; i++) {
		if (a[i] != -1) {
			memset(dp, 0, sizeof(dp));
			dp[0][0] = 1;
			for (ll j = 0; j < n; j++) {
				for (ll k = 0; k < n; k++) {
					add(dp[j + 1][k], dp[j][k]);
					
					if (j != i) {
						if (a[j] >= 0) {
							bool less = (a[j] < a[i] || (a[j] == a[i] && j < i));
							
							add(dp[j + 1][k + less], 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 (ll k = 0; k <= n; k++) {
				ans = (ans + a[i] * dp[n][k]) % mod;
			}
		}
	}
	
	cout << ans << '\n';
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		auto start = std::chrono::high_resolution_clock::now();
        freopen("fi.txt", "r", stdin);
		freopen("fo.txt", "w", stdout);
	#endif
	
    cout<<setprecision(15)<<fixed;

	int t = 1;
//	cin >> t;
	while (t--)     solve();

	#ifndef ONLINE_JUDGE
		auto end = std::chrono::high_resolution_clock::now();
        cerr<<setprecision(4)<<fixed;
		cerr<<"Execution Time : "<<std::chrono::duration_cast<std::chrono::duration<double>>(end-start).count()<<" ms"<<endll;	
	#endif
	return 0;
}