#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b) - 1; i >= (a); --i)
#define reT() int T; scan_d(T); rep(t, 0, T)
#define de(x) cout << #x << " = " << x << endl
#define dd(x) cout << #x << " = " << x << " "
#define da(x, a, b) for(int i = (a); i < (b); ++i) cout << "\t(" << i << ")" << x[i] << " \n"[i == b - 1];
#define pw(x) (1ll<<(x))
#define modadd(a,b) {a+=b;a%=MOD;}
#define modmul(a,b) {a*=b;a%=MOD;}
#define LL long long
#define IN freopen("in", "r", stdin)
#define OUT freopen("out", "w", stdout)
using namespace std;
const int inf = 0x3f3f3f3f;
const int N = 510;
const int MOD = 998244353;

template <typename T>
inline bool scan_d(T& ret) { char c; int sgn; if (c = getchar(), c == EOF) return 0; while (c != '-' && (c < '0' || c > '9')) { if ((c = getchar()) == EOF) return 0; }sgn = (c == '-') ? -1 : 1; ret = (c == '-') ? 0 : (c - '0'); while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0'); ret *= sgn; return 1; }
template<typename T>
void print(T x) { static char s[33], * s1; s1 = s; if (!x) *s1++ = '0'; if (x < 0) putchar('-'), x = -x; while (x) *s1++ = (x % 10 + '0'), x /= 10; while (s1-- != s) putchar(*s1); }
template<typename T>
void println(T x) { print(x); putchar('\n'); }
struct TPoint {
	int x, y;
	bool operator<(const TPoint& comp) const { if (x != comp.x) return x < comp.x; return y < comp.y; }
};

int n;
TPoint p[N];
int dn[N], dp[N];

int main() {
#ifdef _LOCAL_JUDGE_
	IN;
	//OUT;
#endif
	while (scan_d(n)) {
		rep(i, 0, n) {
			char op;
			scanf(" %c", &op);

			if (op == '+') {
				int v;
				scan_d(v);
				p[i] = { 1, v };
			}
			else p[i] = { 0, 0 };
		}

		int res = 0;
		rep(id, 0, n) {
			if (p[id].x == 0) continue;

			fill(dn, dn + n + 1, 0);
			fill(dp, dp + n + 1, 0);
			dn[0] = 1;

			rep(i, 0, n) {
				modadd(dn[0], dp[0]);
				dp[0] = 0;

				if (p[i].x) {
					if (i == id) {
						per(j, 1, n + 1) modadd(dp[j], dp[j - 1]);
						per(j, 1, n + 1) modadd(dp[j], dn[j - 1]);
					}
					else if (TPoint({ p[i].y, i }) < TPoint({ p[id].y, id })) {
						per(j, 1, n + 1) modadd(dp[j], dp[j - 1]);
						per(j, 1, n + 1) modadd(dn[j], dn[j - 1]);
					}
					else {
						per(j, 0, n + 1) modmul(dp[j], 2);
						per(j, 0, n + 1) modmul(dn[j], 2);
					}
				}
				else {
					modmul(dp[0], 2);
					modmul(dn[0], 2);
					rep(j, 1, n + 1) modadd(dp[j - 1], dp[j]);
					rep(j, 1, n + 1) modadd(dn[j - 1], dn[j]);
				}

				//dd(val), de(i);
				//rep(j, 0, n + 1) dd(j), de(dn[j]);
				//rep(j, 0, n + 1) dd(j), de(dp[j]);
			}


			LL sum = 0;
			rep(j, 1, n + 1) modadd(sum, (LL)dp[j]);
			modmul(sum, (LL)p[id].y);
			modadd(res, (int)sum);
		}

		println(res);
	}
	return 0;
}