﻿#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;

int add(int a, int b) {
	int res = a + b;
	if (res >= mod) {
		res %= mod;
	}
	return res;
}

void solve() {
	int n;
	cin >> n;
	vector<int> x(n + 1);
	for (int i = 1; i <= n; ++i) {
		char ch;
		cin >> ch;
		if (ch == '+') {
			cin >> x[i];
		}
	}
	vector<vector<int>> dp(n + 1, vector<int>(n + 1)); dp[0][0] = 1;
	int ans = 0;
	for (int k = 1; k <= n; ++k) {
		if (x[k] == 0) { continue; }
		for (int i = 1; i <= n; ++i) {
			for (int j = 0; j <= i - (i >= k); ++j) {
				if (i != k) {
					dp[i][j] = dp[i - 1][j];
				}
				if (x[i] == 0) {
					dp[i][j] = add(dp[i][j], dp[i - 1][j + 1]);
					if (j == 0 && i < k) {
						dp[i][j] = add(dp[i][j], dp[i - 1][j]);
					}
				} else {
					if (x[i] > x[k] || (x[i] == x[k] && i >= k)) {
						dp[i][j] = add(dp[i][j], dp[i - 1][j]);
					} else if (j > 0) {
						dp[i][j] = add(dp[i][j], dp[i - 1][j - 1]);
					}
				}
			}
		}
		int cnt = 0;
		for (int j = 0; j < n; ++j) {
			cnt = add(cnt, dp[n][j]);
		}
		ans = add(ans, (cnt * 1ll * x[k]) % mod);
		for (int i = 1; i <= n; ++i) {
			for (int j = 0; j < n; ++j) {
				dp[i][j] = 0;
			}
		}
	}
	cout << ans << '\n';
}

int main() {
    ios_base::sync_with_stdio(0);
	cin.tie(0);
    cout.tie(0);
	
	int t; t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}

    return 0;
}
