#include <bits/stdc++.h>

using namespace std;

const int N = (int) 502;
const int mod = (int) 998244353;

long long TH, THI, n, a[N], dp[N][N];
char s[N];

int sol(int i, int j) {
	if (i == n) {
		return 1;
	}
	long long& ret = dp[i][j];
	if (ret != -1) {
		return ret;
	}
	if (i == THI) {
		ret = sol(i + 1, j);
	} else if (i > THI) {
		ret = sol(i + 1, j);
		if (s[i] == '+') {
			ret += sol(i + 1, j + (a[i] < TH));
		} else if (j > 0) {
			ret += sol(i + 1, j - 1);
		}
		ret %= mod;
	} else {
		ret = sol(i + 1, j);
		if (s[i] == '-') {
			ret += sol(i + 1, max(j - 1, 0));
		} else {
			ret += sol(i + 1, j + (a[i] <= TH));
		}
		ret %= mod;
	}
	return ret % mod;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		if (s[i] == '+') {
			cin >> a[i];
		}
	}
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == '+') {
			TH = a[i];
			THI = i;
			memset(dp, -1, sizeof dp);
			ans += a[i] * 1LL * sol(0, 0) % mod;
			ans %= mod;
		}
	}
	cout << ans << '\n';
	return 0;
}
// D
