#include<bits/stdc++.h>
using namespace std;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define rep(i,a,b) for(i=(a);i<=(b);++i)
#define per(i,a,b) for(i=(a);i>=(b);--i)
#define REP(i,a,b) for(i=(a);i< (b);++i)
#define PER(i,a,b) for(i=(a);i> (b);--i)
#define ERR(...) fprintf(stderr,__VA_ARGS__)
template<class T>inline void cmn(T &x,const T &a){if(a<x)x=a;}
template<class T>inline void cmx(T &x,const T &a){if(x<a)x=a;}
template<class T>inline bool bmn(T &x,const T &a){if(a<x){x=a;return true;}else return false;}
template<class T>inline bool bmx(T &x,const T &a){if(x<a){x=a;return true;}else return false;}
template<class T>inline T gcd(const T &a,const T &b){
	if(a&&b){
		T x=a,y=b;
		for(;;){
			if(!(x%=y))return y;
			if(!(y%=x))return x;
		}
	}else return a|b;
}
const int p=998244353;
//const int p=1000000007;
const int ps2=p-2;
inline void add(int &x){if(x>=p)x-=p;}
inline void sub(int &x){if(x< 0)x+=p;}
#define MUL(a,b) ((0ll|(a))*(b)%p)
template<class T>int expo(int a,T b){
	int s(1);
	while(b){if(b&1)s=MUL(s,a);b>>=1;a=MUL(a,a);}
	return s;
}
int expo(int a){
	int b(ps2),s(1);
	while(b){if(b&1)s=MUL(s,a);b>>=1;a=MUL(a,a);}
	return s;
}
const int MAXN=505;
int A[MAXN],F[MAXN];
signed main(){
#ifdef ONLINE_JUDGE
	//freopen("problemname.in","r",stdin);
	//freopen("problemname.out","w",stdout);
#endif
	int N;
	scanf("%d",&N);
	int i;
	{
		char c[2];
		REP(i,0,N){
			scanf("%s",c);
			if(c[0]=='+')scanf("%d",&A[i]);
		}
	}
	//REP(i,0,N)ERR("%d ",A[i]);ERR("A\n");
	int a,t,j,b,k,Ans=0;ll Tmp;
	REP(i,0,N)if(a=A[i]){
		t=0;
		(*F)=1;
		//ERR("i=%d a=%d\n",i,a);

		REP(j,0,i){
			if(b=A[j]){
				if(b<=a){
					//+ b
					F[t+1]=F[t];
					per(k,t-1,0)add(F[k+1]+=F[k]);
					++t;
				}else{
					rep(k,0,t)add(F[k]<<=1);
				}
			}else{
				add((*F)<<=1);
				REP(k,0,t)add(F[k]+=F[k+1]);
			}
			//ERR("j=%d\n",j);
			//rep(k,0,t)ERR("%d ",F[k]);ERR("F\n");
		}

		REP(j,i+1,N){
			if(b=A[j]){
				if(b<a){
					//+ b
					F[t+1]=F[t];
					per(k,t-1,0)add(F[k+1]+=F[k]);
					++t;
				}else{
					rep(k,0,t)add(F[k]<<=1);
				}
			}else{
				REP(k,0,t)add(F[k]+=F[k+1]);
			}
			//ERR("j=%d\n",j);
			//rep(k,0,t)ERR("%d ",F[k]);ERR("F\n");
		}

		Tmp=0ll;
		rep(j,0,t)Tmp+=F[j];
		Ans=(Ans+(Tmp%p)*a)%p;
	}
	printf("%d\n",Ans);
	return 0;
}