#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
using ll = long long;

const int mod = 998244353;
ll dp[512][512];

int n;
vector<pair<int, int>> A;
ll go(ll j, ll i, ll lesser) {
  if (i >= n)
    return 1;
  if (dp[i][lesser] != -1)
    return dp[i][lesser];
  if (i == j)
    return go(j, i + 1, lesser);
  if (i < j) {
    if (A[i].first == 1) {
      ll s1 = go(j, i + 1, lesser);
      ll s2 = go(j, i + 1, (A[i].second <= A[j].second) + lesser);
      return dp[i][lesser] = (s1 +  s2) % mod;
    }
    else {
      ll s1 = go(j, i + 1, lesser);
      ll s2 = go(j, i + 1, max(0LL, lesser - 1));
      return dp[i][lesser] = (s1 + s2) % mod;
    }
  }
  else {
    if (A[i].first == 1) {
      ll s1 = go(j, i + 1, lesser);
      ll s2 = go(j, i + 1, (A[i].second < A[j].second) + lesser);
      return dp[i][lesser] = (s1 +  s2) % mod;
    }
    else {
      ll s1 = go(j, i + 1, lesser);
      ll s2 = 0;
      if (lesser > 0) {
        s2 = go(j, i + 1, lesser - 1);
      }
      return dp[i][lesser] = (s1 + s2) % mod;
    }
  }
}

int main() {
  ios::sync_with_stdio(false);

  cin >> n;
  for (int i = 0; i < n; i++) {
    char c;
    cin >> c;
    if (c == '+') {
      int x;
      cin >> x;
      A.emplace_back(1, x);
    }
    else
      A.emplace_back(0,0);
  }

  ll answer = 0;
  for (int i = 0; i < n; i++) {
    if (A[i].first == 1) {
      memset(dp, -1, sizeof dp);
      ll add = (go(i,0,0) * A[i].second) % mod;
      answer = (answer + add) % mod;
    }
  }
  cout << answer << "\n";

  return 0;
}
