#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=998244353;
int l,m,n,t,x,y,z,k;
int a[510],sum[510];
ll dp[510][510],ans;
char s[510];
int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
    {
    	cin>>s[i];
    	sum[i]=sum[i-1];
    	if (s[i]=='+') scanf("%d",&a[i]),sum[i]++;
	}
	for	(int x=1;x<=n;x++)
	if (s[x]=='+')
	{
		memset(dp,0,sizeof(dp));
		dp[0][0]=1;
		for (int i=1;i<=n;i++)
			for (int j=0;j<=sum[i];j++)
			{
				if (x!=i) dp[i][j]=dp[i-1][j];
				if (s[i]=='+')
				{
					if (a[i]<a[x]||a[i]==a[x]&&i<x) dp[i][j]=(dp[i][j]+dp[i-1][j-1])%mod;
					else dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
				}
				else
				{
					if (i<x)
					{
						if (j==0) dp[i][j]=(dp[i][j]+dp[i-1][0]+dp[i-1][1])%mod;
						else dp[i][j]=(dp[i][j]+dp[i-1][j+1])%mod;
					}
					else dp[i][j]=(dp[i][j]+dp[i-1][j+1])%mod;
				}
			}
		for (int j=0;j<=sum[n];j++) ans=(ans+dp[n][j]*a[x])%mod;
	}
	printf("%lld\n",ans);
    return 0;
}