#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>
#include <queue>
#define int long long
#define mod 998244353
using namespace std;
int n,c[505],a[505],f[505][505],pos,ans;
char s[15];
int dfs(int now,int nowd){
	if (now>n)return 1;
	if (now==pos)return dfs(now+1,nowd+1);
	if (f[now][nowd]!=-1)return f[now][nowd];
	int ans=0;
	if (now<pos)ans=dfs(now+1,nowd)+dfs(now+1,max(0ll,nowd+a[now]));
	else{
		ans=dfs(now+1,nowd);
		if (nowd+a[now]>0)ans+=dfs(now+1,nowd+a[now]);
	}
	ans%=mod;
	return f[now][nowd]=ans;
}
signed main(){
	cin>>n;
	for (int i=1;i<=n;i++){
		scanf("%s",s+1);
		if (s[1]=='-')c[i]=-1;
		else scanf("%lld",&c[i]);
	}
	for (int i=1;i<=n;i++){
		if (c[i]==-1)continue;
		for (int j=1;j<=n;j++){
			if (c[j]==-1)a[j]=-1;
			else if (c[j]<c[i]||(c[j]==c[i]&&j<i))a[j]=1;
			else a[j]=0;
		}
		memset(f,-1,sizeof(f));
		pos=i;
		ans=(ans+c[i]*dfs(1,0))%mod;
	}
	cout<<ans<<endl;
	return 0;
}