//If you can dream it, you can do it!
//author@nowadays - 2021-07-06  22:07:56
#include <bits/stdc++.h>
using namespace std;

const int mod = 998244353;

void add(long long& a, long long b) {
    a += b;
    a %= mod;
}

int main() {
    ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
    int n;
    cin >> n;
    vector<long long> a(n + 1);
    for (int i = 1; i <= n; ++i) {
        char ch;
        cin >> ch;
        if (ch == '+') {
            cin >> a[i];
        } else {
            a[i] = 0;
        }
    }
    vector<vector<long long>> dp(n + 2, vector<long long>(n + 2, 0));
    long long ans = 0;
    for (int pos = 1; pos <= n; ++pos) {
        if (a[pos] == 0) {
            continue;
        }
        for (int i = 0; i <= n; ++i) {
            for (int j = 0; j <= n; ++j) {
                dp[i][j] = 0;
            }
        }
        dp[0][0] = 1;
        for (int i = 1; i <= n; ++i) {
            for (int j = 0; j <= i; ++j) {
                if (a[i] == 0) {
                    if (j > 0 || (i <= pos)) {
                        add(dp[i][max(j - 1, 0)], dp[i - 1][j]);
                    }
                } else {
                    if ((a[i] == a[pos] && i < pos) || a[i] < a[pos]) {
                        add(dp[i][j + 1], dp[i - 1][j]);
                    } else {
                        add(dp[i][j], dp[i - 1][j]);
                    }
                }
                if (i != pos)
                add(dp[i][j], dp[i - 1][j]);
            }
        }
        for (int i = 0; i <= n; ++i) {
            add(ans, a[pos] * dp[n][i]);
        }
    }
    cout << ans << "\n";
    return 0;
}