#include <bits/stdc++.h>
#define ll long long
#define ld long double

using namespace std;

const ll MOD = 998244353;
const ll INF = 1e9;

int dp[502][502], n, a[502];
char op[502];

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> op[i];
    if (op[i] == '+')
      cin >> a[i];
  }
  int ans = 0;
  for (int l = 1; l <= n; l++) {
    if (a[l] > 0) {
      for (int i = 0; i <= n; i++)
        for (int j = 0; j <= n; j++)
          dp[i][j] = 0;
      dp[0][0] = 1;
      for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= i; j++) {
          if (a[i] == 0) {
            if (i <= l || j > 0)
              dp[i][max(j - 1, 0)] = (dp[i - 1][j] + dp[i][max(j - 1, 0)]) % MOD;
          }
          else if (a[i] < a[l] || (a[i] == a[l] && i < l))
            dp[i][j + 1] = (dp[i][j + 1] + dp[i - 1][j]) % MOD;
          else 
            dp[i][j] = (dp[i][j] + dp[i - 1][j]) % MOD;
          if (i != l)
            dp[i][j] = (dp[i][j] + dp[i - 1][j]) % MOD;
        }
      }
    }
    for (int j = 0; j <= n; j++)
      ans = (ans + 1ll * dp[n][j] * a[l] % MOD) % MOD;
  }
  cout << ans;
  return 0;
}
