#pragma GCC optimize("Ofast")
#include <bits/stdc++.h> 
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
const int mod = 998244353;
void solve(){
    int n;
    char c;
    cin >> n;
    vector<int> a(n + 1, 0);
    for(int i = 1; i <= n; i++) {
        cin >> c;
        if (c == '+') cin >> a[i];
    }
    //for(int i = 1; i <= n; i++) cout << a[i] << endl;
    ll ans = 0;
    for(int x = 1; x <= n; x++) {
        if (a[x] == 0) continue;
        int dp[n+1][n+1];
        memset(dp, 0, sizeof(dp));
        dp[0][0] = 1;
        for(int i = 1; i <= n; i++) {
            for(int j = 0; j < n; j++) {
                if (a[i] == 0) {
                    if(i < x || j > 0) {
                        dp[i][max(j - 1, 0)] = (dp[i - 1][j] + dp[i][max(j - 1, 0)]) % mod;
                    }
                }
                else {
                    if (a[i] < a[x] || (a[i] == a[x] && i < x)) 
                        dp[i][j + 1] = (dp[i - 1][j] + dp[i][j + 1]) % mod;
                    else
                        dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod;
                }
                if (i != x) dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod;
            }
        }
        for(int j = 0; j <= n; j++) ans = (ans + 1ll * a[x] * dp[n][j]) % mod; 
    }
    cout << ans << endl;
}
int main()
{
    fast_cin();
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ll t = 1;
    //cin >> t;
    for(int it=1;it<=t;it++) {
        solve();
    }
    return 0;
}