#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
using LL = long long;
const int MOD = 998244353;
int n, x[510], idx[510];
LL f[510][510];
char op[510][2];

LL pw2(int p)
{
    if (!p) return 1;
    LL t = pw2(p / 2);
    if (p % 2)
        return t * t % MOD * 2 % MOD;
    else
        return t * t % MOD;
}

int main()
{
    // freopen("d.in", "r", stdin);
    // freopen("d.out", "w", stdout);
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        scanf("%s", op[i]);
        if (op[i][0] == '+')
            scanf("%d", &x[i]);
    }
    for (int i = 1; i <= n; i++)
        idx[i] = i;
    sort(idx + 1, idx + n + 1, [](int i, int j){return x[i] == x[j] ? i < j : x[i] < x[j];});
    LL ans = 0;
    for (int i = 1; i <= n; i++)
    {
        if (!x[idx[i]]) continue;
        memset(f, 0, sizeof(f));
        f[0][0] = 1;
        for (int j = 1; j < idx[i]; j++)
            for (int k = 0; k <= j; k++)
                if (op[j][0] == '+' && x[j] > x[idx[i]])
                    f[j][k] = f[j - 1][k];
                else if (op[j][0] == '+')
                    f[j][k] = ((k ? f[j - 1][k - 1] : 0) + f[j - 1][k]) % MOD;
                else
                    f[j][k] = (f[j - 1][k] * (k ? 1 : 2) + f[j - 1][k + 1]) % MOD;
        f[n + 1][0] = 1;
        for (int j = n; j > idx[i]; j--)
            for (int k = 0; k <= n - j + 1; k++)
                if (op[j][0] == '+' && x[j] >= x[idx[i]])
                    f[j][k] = f[j + 1][k];
                else if (op[j][0] == '-')
                    f[j][k] = ((k ? f[j + 1][k - 1] : 0) + f[j + 1][k]) % MOD;
                else
                    f[j][k] = (f[j + 1][k] * (k ? 1 : 2) + f[j + 1][k + 1]) % MOD;
        LL s = 0, t = 0;
        for (int j = 0; j < idx[i]; j++)
        {
            t = (t + f[idx[i] + 1][j]) % MOD;
            s = (s + f[idx[i] - 1][j] * t) % MOD;
        }
        ans = (ans + s * pw2(n - i) % MOD * x[idx[i]]) % MOD; 
    }
    printf("%lld\n", ans);
    return 0;
}