#include <bits/stdc++.h>

using namespace std;

const int MOD = 998244353;
const int N = 555;
char type[N];
long long a[N], b[N], dp[N][N];

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> type[i];
        if (type[i] == '+') cin >> a[i];
    }
    long long ans = 0;
    for (int i = 1; i <= n; ++i) if (type[i] == '+') {
        // choose this;
        memset(dp, 0, sizeof (dp));
        for (int j = 1; j <= n; ++j) {
            if (type[j] == '-') {
                b[j] = -1;
                continue;
            }
            b[j] = a[j] < a[i];
            if (a[j] == a[i]) b[j] = j <= i;
        }
        dp[0][0] = 1;
        for (int j = 1; j <= n; ++j) {
            for (int pos = 0; pos <= j; ++pos) if (dp[j - 1][pos]) {
                if (i != j) dp[j][pos] = (dp[j - 1][pos] + dp[j][pos]) % MOD;
                int newPos = pos + b[j];
                // cerr << "Update" << j << ' ' << pos << ' ' << newPos << ' ' << dp[j - 1][pos] << '\n';
                if (j < i) {
                    newPos = max(0, newPos);
                } else {
                    if (newPos <= 0) continue;
                }
                dp[j][newPos] = (dp[j - 1][pos] + dp[j][newPos]) % MOD;   
            }
        }
        for (int pos = 1; pos <= n; ++pos) {
            // cerr << i << ' ' << a[i] << ' ' << pos << ' ' << dp[n][pos] << '\n';
            ans = (ans + 1ll * a[i] * dp[n][pos]) % MOD;
        }
    }
    cout << ans << '\n';
}