// Anything but not everything
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define REP(i,a,b) for(int i = (int)(a); i < (int)(b); ++ i)
#define pb push_back
#define sz(x) (int)(x.size())
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ff first
#define ss second
typedef long long ll;
typedef pair<int,int> ii;
typedef long double ld;

const int N = 5e2 + 2;
const int Mod = 998244353;

int dp[N][N];

int main(){
	fastio;
	int n; cin >> n;
	vector<int> vec(n,0);
	REP(i,0,n){
		char c; cin >> c;
		if(c == '-') continue;
		cin >> vec[i];
	}

	function<int(int,int)> get_low = [&](int i, int p){
		if(vec[i] != vec[p]) return vec[i] < vec[p];
		return i < p;
	};

	function<int(int,int,int)> run_dp = [&](int i, int men, int p){
		if(i == n) return 1;
		int &ans = dp[i][men];
		if(ans != -1) return ans;

		ans = 0;
		if(i == p) return ans = run_dp(i+1,men,p);
		
		if(!vec[i]) {
			int add = 0;
			if(men == 0){
				if(i < p) add = run_dp(i+1,0,p);
			}
			else add = run_dp(i+1,men-1,p);
			return ans = (add + run_dp(i+1,men,p)) % Mod;
		}
		return ans = (run_dp(i+1,men,p) + run_dp(i+1,men+get_low(i,p),p)) % Mod; 
	};

	int ans = 0;

	REP(p,0,n){
		if(vec[p] == 0) continue;
		REP(i,0,n) REP(j,0,n) dp[i][j] = -1;
		int cnt = run_dp(0,0,p);
		ans += (1LL * cnt * vec[p]) % Mod;
		if(ans >= Mod) ans -= Mod;
	}
	
	cout << ans << endl;

	return 0;
}

