#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

const int N = 500 + 10, P = 998244353;

int n, a[N];
long long dp[N][N];

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
	{
		char op[3];
		scanf("%s", op);
		if (*op == '-')
			a[i] = -1;
		else
			scanf("%d", a + i);
	}
	long long ans = 0;
	for (int p = 1; p <= n; ++p)
	{
		if (a[p] < 0)
			continue;
		int x = a[p];
		memset(dp, 0, sizeof dp);
		dp[0][0] = 1;
		for (int i = 1; i <= n; ++i)
		{
			if (i == p)
			{
				memcpy(dp[i], dp[i - 1], sizeof dp[i]);
				continue;
			}
			for (int j = 0; j <= n; ++j)
			{
				if (a[i] < 0)
				{
					dp[i][j] = (dp[i - 1][j] + dp[i - 1][j + 1]) % P;
					if (j == 0 && i < p)
						(dp[i][j] += dp[i - 1][j]) %= P;
				}
				else if (a[i] < x || (a[i] == x && i < p))
				{
					dp[i][j] = dp[i - 1][j];
					if (j > 0)
						(dp[i][j] += dp[i - 1][j - 1]) %= P;
				}
				else
					dp[i][j] = 2 * dp[i - 1][j] % P;
			}
		}

		long long sum = 0;
		for (int j = 0; j <= n; ++j)
			(sum += dp[n][j]) %= P;
		(ans += sum * x % P) %= P;
	}
	printf("%lld\n", ans);
	return 0;
}
