#include <iostream>
#include <string.h>

using namespace std;

constexpr int MOD = 998244353;

int a[505];
char s[2];
int dp[2][505];

int main(void) {
	int n;
	scanf("%d", &n);
	for (int i = 0;i < n;i++) {
		scanf("%s", s);
		if (s[0] == '+') {
			scanf("%d", &a[i]);
		} else a[i] = -1;
	}
	int ans = 0;
	for (int i = 0;i < n;i++) {
		if (a[i] < 0) continue;
		memset(dp, 0, sizeof(dp));
		int now = 0;
		dp[now][0] = 1;
		for (int j = 0;j < n;j++) {
			if (j == i) continue;
			for (int k = 0;k < n;k++) dp[now ^ 1][k] = dp[now][k];
			if (a[j] > 0) {
				if ((a[j] == a[i] && j < i) || a[j] < a[i]) {
					for (int k = 0;k < n;k++) {
						dp[now ^ 1][k + 1] += dp[now][k];
						dp[now ^ 1][k + 1] %= MOD;
					}
				} else {
					for (int k = 0;k < n;k++) {
						dp[now ^ 1][k] += dp[now][k];
						dp[now ^ 1][k] %= MOD;
					}
				}
			} else {
				for (int k = 1;k < n;k++) {
					dp[now ^ 1][k - 1] += dp[now][k];
					dp[now ^ 1][k - 1] %= MOD;
				}
				if (j < i) {
					dp[now ^ 1][0] += dp[now][0];
					dp[now ^ 1][0] %= MOD;
				}
			}
			now ^= 1;
		}
		for (int j = 0;j < n;j++) {
			ans += 1ll * a[i] * dp[now][j] % MOD;
			ans %= MOD;
		}
	}
	printf("%d\n", ans);
	return 0;
}