#include <bits/stdc++.h>

#define endl '\n'
#define IOS std::ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mp make_pair
#define seteps(N) fixed << setprecision(N) 
typedef long long ll;

using namespace std;
/*-----------------------------------------------------------------*/

ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
#define INF 0x3f3f3f3f
const int N = 510;
const int M = 998244353;

ll dp[N][N];
ll arr[N];
bool flag[N];

int main() {
    IOS;
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++) {
        char ch;
        cin >> ch;
        if(ch == '-') {
            flag[i] = true;
        } else {
            cin >> arr[i];
        }
    }
    ll ans = 0;
    for(int I = 1; I <= n; I++) {
        if(flag[I]) continue;
        memset(dp, 0, sizeof dp);
        dp[0][0] = 1;
        ll V = arr[I];
        for(int i = 1; i <= n; i++) {
            if(flag[i]) {
                for(int j = 0; j <= i; j++) {
                    dp[i][j] = (dp[i - 1][j] + dp[i - 1][j + 1]) % M;
                    if(j == 0) dp[i][j] += dp[i - 1][j];
                    dp[i][j] %= M;
                }
            } else if(i == I) {
                for(int j = 0; j <= i; j++) {
                    if(j - 1 >= 0) dp[i][j] = dp[i - 1][j - 1];
                }
            } else if(i < I){
                if(arr[i] <= V) {
                    for(int j = 0; j <= i; j++) {
                        dp[i][j] = dp[i - 1][j];
                        if(j - 1 >= 0) dp[i][j] += dp[i - 1][j - 1];
                        dp[i][j] %= M;
                    }
                } else {
                    for(int j = 0; j <= i; j++) {
                        dp[i][j] = 2 * dp[i - 1][j] % M;
                    }
                }
            } else {
                if(arr[i] < V) {
                    for(int j = 0; j <= i; j++) {
                        dp[i][j] = dp[i - 1][j];
                        if(j - 1 > 0) dp[i][j] += dp[i - 1][j - 1];
                        dp[i][j] %= M;
                    }
                } else {
                    for(int j = 0; j <= i; j++) {
                        dp[i][j] = 2 * dp[i - 1][j] % M;
                    }
                }
            }
        }
        for(int i = 1; i <= n; i++) {
            ans += V * dp[n][i] % M;
            ans %= M;
        }
    }
    cout << ans << endl;
}