#include<bits/stdc++.h>
using namespace std;
#define int long long
int mod = 998244353;
typedef array<int, 2> pii;

int32_t main(){
 ios::sync_with_stdio(0); cin.tie(0);
  // dp[i][rimossi]?
 int n; cin >> n;
 vector<pii> v(n);
 for(pii& p : v){
  char c; cin >> c;
  int i = 0;
  if(c == '+') cin >> i;
  p = {(c == '+'), i};
 }
 vector<int> pp(n+2);
 pp[0] = 1;
 for(int i = 1; i <= n; ++i) pp[i] = pp[i-1] * 2 % mod;
 int ans = 0;
 for(int lo = 0; lo < n; ++lo){
  if(v[lo][0] == 0) continue;
  // count subseqs where value at index lo is present
  vector<int> dp(n+2, 0);
  dp[0] = 1;
  int his = 0;
  for(int i = 0; i < n; ++i){
   if(v[i][0] == 0){ // rm val
    if(i < lo) dp[0] += dp[0]; // remove from empty set
    for(int i = 0; i < n; ++i) dp[i] += dp[i+1], dp[i] %= mod;
    // ogni conta di valori bassi: o erano cosi, o ne levo uno
   }
   else if(v[i][1] < v[lo][1] || (v[i][1] == v[lo][1] && i < lo)){ // add val
    for(int i = n; i; --i) dp[i] += dp[i-1], dp[i] %= mod;
   }
   else ++his;
  }
  int cntlo = 0;
  for(int i : dp) cntlo += i;
  cntlo %= mod;
  // ans += 2**his * cntlo * value at lo
  ans += pp[his - 1] * cntlo % mod * v[lo][1] % mod;
  //cout << v[lo][1] << " " << his - 1 << " " << cntlo << endl;
  ans %= mod;
 }
 cout << ans << endl;
 // quante subseq lasciano ciascun val
 // il valore c'è * any valori maggiori * dp sui piccoli e 
}