/*---Don't look at the standing---*/
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll N = 200004, mod = 1e9 + 7;
char a[N];
ll b[N], dp[505][505];
int j, n;

ll solve(int i, int cnt) {
        if (cnt < 0) {
                if (i > j)
                        return 0;
                cnt = 0;
        }
        if (i == n)
                return 1;
        ll &ret = dp[i][cnt];
        if (~ret)
                return ret;
        if (i == j) {
                return ret = solve(i + 1, cnt) % 998244353;
        }
        if (a[i] == '-') {
                ret = solve(i + 1, cnt - 1) + solve(i + 1, cnt) % 998244353;
        } else {
                if (b[i] < b[j] || (b[i] == b[j] && i < j)) {
                        ret = solve(i + 1, cnt + 1) + solve(i + 1, cnt) % 998244353;
                } else
                        ret = solve(i + 1, cnt) + solve(i + 1, cnt) % 998244353;
        }
        return ret % 998244353;
}

int main() {
        ios_base::sync_with_stdio(0), cin.tie(0);
        #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        #endif
        cin >> n;
        for (int i = 0; i < n; i++) {
                cin >> a[i];
                if (a[i] == '+')
                        cin >> b[i];
        }
        ll ans = 0;
        for (int i = 0; i < n; i++) {
                if (a[i] == '+') {
                        memset(dp, -1, sizeof dp);
                        ll X = b[i];
                        j = i;
                        ans += 1ll * X * solve(0, 0);
                        ans %= 998244353;
                }
        }
        cout << ans << endl;
}