#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define makev(a, n) vector<int> a(n, 0)
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define printv(v) rep(i, (int)v.size()) cout << v[i] << (i+1 == (int)v.size() ? "\n" : " ");
#define rfor(i, a, b) for (int i = a; i < b; i++)
const vector<int> maze = {0, 1, 0, -1, 0};
const int mod = 1e9+7;
ll gcd(ll a, ll b) {return b == 0 ? abs(a) : gcd(b, a%b);}
ll lcm(ll a, ll b) {return a*b/gcd(a, b);}
ll extgcd(ll a, ll b, ll &x, ll &y) {if (b == 0) {x = 1; y = 0;return a;} else {ll d = extgcd(b, a % b, y, x);y-=a/b*x;return d;}}
ll modpow(ll x, ll n, ll p) {ll ans = 1;while (n > 0) {if (n&1) ans = ans*x%p;x = x*x%p;n >>= 1;}return ans;}

int main() {
  int n; cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];
  vector<ll> dp0(n+1, 0); dp0[0] = 1;
  vector<ll> dp1(n+1, 0); dp1[0] = 1;
  rfor(i, 1, n+1) {
    if (s[i-1] == "AND") {
      dp0[i] = dp0[i-1]*2+dp1[i-1];
      dp1[i] = dp1[i-1];
    } else {
      dp0[i] = dp0[i-1];
      dp1[i] = dp0[i-1]+dp1[i-1]*2;
    }
  }
  cout << dp1[n] << endl;
}
#include <bits/stdc++.h>
using namespace std;
const int P = (int) 998244353;
int main() {
 cin.tie(nullptr)->sync_with_stdio(false);
 int n;
 cin >> n;
 vector<int> w(n);
 for (int i = 0; i < n; i++) {
  cin >> w[i];
 }
 int s = accumulate(begin(w), end(w), 0);
 if (s % 2 == 1) {
  cout << 0 << endl;
 } else {
  vector<vector<int>> f(n + 1, vector<int>(s / 2 + 1, 0));
  f[0][0] = 1;
  for (int i = 0; i < n; i++) {
   for (int j = i; j >= 0; --j) {
    for (int k = 0; k + w[i] <= s / 2; k++) {
     int &trans = f[j + 1][k + w[i]];
     trans += f[j][k];
     trans -= P;
     trans += trans >> 31 & P;
    }
   }
  }
  vector<int> fact(n + 1);
  fact[0] = 1;
  for (int i = 0; i < n; i++) {
   fact[i + 1] = (long long) fact[i] * (i + 1) % P;
  }
  int ans = 0;
  for (int i = 0; i <= n; i++) {
   ans += (long long) fact[i] * fact[n - i] % P * f[i][s / 2] % P;
   ans -= P;
   ans += ans >> 31 & P;
  }
  cout << ans << endl;
 }
}
