#include <bits/stdc++.h>
using namespace std;

long long cur[101][10001], pre[101][10001];
long long MOD = 998244353;
int main() {
    int N; cin >> N;
    vector<int> W(N);
    for(int i = 0; i < N; i++) {
        cin >> W[i];
    }
    pre[0][0] = 1LL;

    int sum = 0;
    for(int i = 0; i < N; i++)
        sum += W[i];
    for(int i = 1; i <= N; i++) {
        for(int make = 0; make <= sum; make++) {
            for(int use = 0; use <= N; use++) {
                cur[use][make] = pre[use][make];
                if(W[i - 1] <= make && use > 0)
                    cur[use][make] += pre[use - 1][make - W[i - 1]];
                if(cur[use][make] > MOD) cur[use][make] -= MOD;
            }
        }
        for(int make = 0; make <= sum; make++)
            for(int use = 0; use <= N; use++)
                pre[use][make] = cur[use][make];
    }
    vector<long long> f(N + 1);
    f[0] = 1LL;
    for(int i = 1; i <= N; i++)
        f[i] = f[i - 1] * 1LL * i % MOD;
    long long ans = 0LL;
    if(sum % 2) {
        cout << 0 << "\n";
        return 0;
    }
    for(int use = 0; use <= N; use++) {
        ans += f[use] * 1LL * f[N - use] % MOD * pre[use][sum / 2] % MOD;
        ans %=  MOD;
    }
    if(ans < 0) ans += MOD;
    cout << ans;
}

#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
const int mod = (int)1e9 + 7;
const int maxN = 1005;
int fib[maxN];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    char caa, cab, cba, cbb;
    cin >> caa >> cab >> cba >> cbb;
    if (n == 2) {
        cout << 1;
        return 0;
    }
    if (cab == 'A') {
        if (caa == 'A') {
            cout << 1;
            return 0;
        }
        if (cba == 'A') {
            n -= 3;
            fib[0] = 1;
            fib[1] = 2;
            for (int i = 2; i <= n; i++) {
                fib[i] = (fib[i - 2] + fib[i - 1]) % mod;
            }
            cout << fib[n];
            return 0;
        }
        else {
            int ans = 1;
            n -= 3;
            for (int i = 1; i <= n; i++) ans = (1LL * ans * 2) % mod;
            cout << ans;
            return 0;
        }
    }
    else {
        if (cbb == 'B') {
            cout << 1;
            return 0;
        }
        if (cba == 'B') {
            n -= 3;
            fib[0] = 1;
            fib[1] = 2;
            for (int i = 2; i <= n; i++) {
                fib[i] = (fib[i - 2] + fib[i - 1]) % mod;
            }
            cout << fib[n];
            return 0;
        }
        else {
            int ans = 1;
            n -= 3;
            for (int i = 1; i <= n; i++) ans = (1LL * ans * 2) % mod;
            cout << ans;
            return 0;
        }
    }
    return 0;
}

