#include <bits/stdc++.h>

using namespace std ;

const int mod = 998244353 ;

int Add(int x , int y)
{
	int z = x + y ;
	if(z >= mod)
		z -= mod ;
	return z ;
}

int Sub(int x , int y)
{
	int z = x - y ;
	if(z < 0)
		z += mod ;
	return z ;
}

int Mul(int x , int y)
{
	return (x * 1ll * y) % mod ;
}

int powlog(int base , int power)
{
	if(power == 0)
		return 1 ;
	int x = powlog(base , power / 2) ;
	x = Mul(x , x) ;
	if(power & 1)
		x = Mul(x , base) ;
	return x ;
}

int modinv(int x)
{
	return powlog(x , mod-2) ;
}

int Div(int x , int y)
{
	return Mul(x , modinv(y)) ;
}

const int MAX = 500 + 10 ;

char c[MAX] ;
int arr[MAX] ;
int n ;

int dp[MAX][MAX] ;
int now ;

int solve(int idx , int cnt)
{
	if(cnt < 0)
	{
		if(idx > now)
			return 0 ;
		cnt = 0 ;
	}
	if(idx == n)
		return 1 ;
	int &ret = dp[idx][cnt] ;
	if(ret != -1)
		return ret ;
	ret = solve(idx+1 , cnt) ;
	if(c[idx] == '-')
		ret = Add(ret , solve(idx+1 , cnt-1)) ;
	else
	{
		if(idx != now)
		{
			if(idx > now && arr[idx] <= arr[now])
				ret = Add(ret , solve(idx+1 , cnt+1)) ;
			else if(idx < now && arr[idx] < arr[now])
				ret = Add(ret , solve(idx+1 , cnt+1)) ;
			else
				ret = Add(ret , solve(idx+1 , cnt)) ;
		}
	}
	return ret ;
}

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	for(int i = 0 ; i < n ; ++i)
	{
		cin>>c[i] ;
		if(c[i] == '+')
			cin>>arr[i] ;
	}
	int ans = 0 ;
	for(int i = 0 ; i < n ; ++i)
	{
		if(c[i] == '-')
			continue ;
		memset(dp , -1 , sizeof(dp)) ;
		now = i ;
		ans = Add(ans , Mul(arr[i] , solve(0 , 0))) ;
	}
	return cout<<ans<<"\n" , 0 ;
}		