#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <ctime>
#include <bitset>
#pragma warning(disable:4996) 

//#define ATCODER
#ifdef ATCODER
#include <atcoder/all>
#endif

typedef long long ll;
typedef unsigned long long ull;
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
const long long MOD = 998244353;

using namespace std;
#ifdef ATCODER
using namespace atcoder;
#endif


ll mpow(ll x, ll n) { //x^n(mod M)
    ll ans = 1;
    while (n != 0) {
        if (n & 1) ans = ans * x % MOD;
        x = x * x % MOD;
        n = n >> 1;
    }
    return ans;
}

ll minv(ll x) {
    return mpow(x, MOD - 2);
}

char str[100];

void solve()
{
    int n;
    scanf("%d", &n);
    ll m2 = minv(2);
    vector<int> a;
    for (int i = 0; i < n; i++) {
        scanf("%s", str);
        if (str[0] == '-') {
            a.push_back(-1);
        }
        else {
            int x;
            scanf("%d", &x);
            a.push_back(x);
        }
    }

    ll ans = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] < 0) continue;
        vector<ll> v(2);
        v[0] = m2;
        v[1] = m2;
        for (int j = 0; j < n; j++) {
            if (j == i) continue;
            if (a[j] < 0) {
                int siz = (int)v.size();
                vector<ll> v2(siz);
                for (int k = 0; k < siz; k++) {
                    if (k == 0) {
                        v2[0] = (v2[0] + v[k]) % MOD;
                    }
                    else if (j < i && k == 1) {
                        v2[k] = (v2[k] + v[k]) % MOD;
                    }
                    else {
                        v2[k - 1] = (v2[k - 1] + v[k] * m2) % MOD;
                        v2[k]     = (v2[k]     + v[k] * m2) % MOD;
                    }
                }
                v.swap(v2);
            }
            else {
                if (a[j] < a[i] || (a[j]==a[i] && j<i)) {
                    int siz = (int)v.size();
                    vector<ll> v2(siz+1);
                    for (int k = 0; k < siz; k++) {
                        if (k == 0) {
                            v2[0] = (v2[0] + v[k]) % MOD;
                        }
                        else {
                            v2[k]     = (v2[k]     + v[k] *m2) % MOD;
                            v2[k + 1] = (v2[k + 1] + v[k] *m2) % MOD;
                        }
                    }
                    v.swap(v2);
                }
                else {
                    ;
                }
            }
        }
        ll ans0 = (1 - v[0] + MOD) * a[i] %MOD;
        ans = (ans + ans0) % MOD;
    }
    ans = ans * mpow(2, n) % MOD;
    printf("%lld\n", ans);
    return;
}

int main()
{
#if 1
    solve();
#else
    int T, t;
    scanf("%d", &T);
    for (t = 0; t < T; t++) {
        //printf("Case #%d: ", t + 1);
        solve();
    }
#endif
    return 0;
}
