#include<bits/stdc++.h>

using namespace std;

#define FOR(i, j, k) for(int i = j; i <= k; i++)
#define ROF(i, j, k) for(int i = j; i >= k; i--)
#define PB push_back
#define MEM(n, val) memset((n), val, sizeof(n))
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define F first
#define S second
#define MP make_pair
#define LL long long
#define MOD 998244353
#define MX 300010
#define INFL 1000000000000000000LL
#define INF 1000000000

typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

int n = 10;
int tot_ch = 26;
int sz[30];

LL ssum(LL a, LL b) {
    return (a + b);
}

LL sum(LL a, LL b) {
    return (a + b) % MOD;
}

LL mul(LL a, LL b) {
    return (a * b) % MOD;
}

LL sub(LL a, LL b) {
    return (((a - b) % MOD) + MOD) % MOD;
}

LL dp1[410];
LL f1(int pos) {
    if(pos == n) {
        return 1;
    }
    if(dp1[pos] != -1) {
        return dp1[pos];
    }
    if(pos <= 1) {
        return dp1[pos] = mul(tot_ch, f1(pos + 1));
    }
    return dp1[pos] = mul(sub(tot_ch, 1), f1(pos + 1));
}

int dp2[410][410][2][2];

int f2(int pos, int taken, bool ppos, bool pppos) {
    if(pos == n) {
        if(taken == 0) {
            return 1;
        }
        return 0;
    }
    if(dp2[pos][taken][ppos][pppos] != -1) {
        return dp2[pos][taken][ppos][pppos];
    }
    LL ans = 0;
    if(pppos) {
        /// can't place ch
        LL gun = sub(tot_ch, 1);
        ans = sum(ans, mul(gun, f2(pos + 1, taken, 0, ppos)));
    }
    else {
        /// can place ch

        /// placing ch
        if(taken) {
            ans = sum(ans, f2(pos + 1, taken - 1, 1, ppos));
        }

        /// not placing ch
        LL gun = sub(tot_ch, 2);
        if(pos <= 1) {
            gun = sub(tot_ch, 1);
        }
        ans = sum(ans, mul(gun, f2(pos + 1, taken, 0, ppos)));
    }
    return dp2[pos][taken][ppos][pppos] = ans;
}

int dp3[2][410][410][3][3];

void f3() {
    ROF(pos, n, 0) {
        FOR(t1, 0, n) {
            FOR(t2, 0, n) {
                FOR(p1, 0, 2) {
                    FOR(pp1, 0, 2) {

                        int pos1 = pos % 2;
                        int pos2 = (pos + 1) % 2;

                        if(pos == n) {
                            if(t1 == 0 && t2 == 0) {
                                dp3[pos1][t1][t2][p1][pp1] = 1;
                                continue;
                            }
                            dp3[pos1][t1][t2][p1][pp1] = 0;
                            continue;
                        }
                        LL ans = 0;
                        if(pp1 == 1) {
                            /// can't place ch1

                            /// placing ch2
                            if(t2)
                                ans = ssum(ans, dp3[pos2][t1][t2 - 1][2][p1]);

                            /// placing others
                            LL gun = sub(tot_ch, 2);
                            ans = ssum(ans, mul(gun, dp3[pos2][t1][t2][0][p1]));
                        }
                        else if(pp1 == 2) {
                            /// can't place ch2

                            /// placing ch1
                            if(t1)
                                ans = ssum(ans, dp3[pos2][t1 - 1][t2][1][p1]);

                            /// placing others

                            LL gun = sub(tot_ch, 2);
                            ans = ssum(ans, mul(gun, dp3[pos2][t1][t2][0][p1]));
                        }
                        else {
                            /// can place all

                            /// placing ch1
                            if(t1)
                                ans = ssum(ans, dp3[pos2][t1 - 1][t2][1][p1]);

                            /// placing ch2
                            if(t2)
                                ans = ssum(ans, dp3[pos2][t1][t2 - 1][2][p1]);

                            /// not placing ch1 and ch2
                            LL gun = sub(tot_ch, 3);
                            if(pos <= 1) {
                                gun = sub(tot_ch, 2);
                            }
                            /// placing others
                            ans = ssum(ans, mul(gun, dp3[pos2][t1][t2][0][p1]));
                        }
                        dp3[pos1][t1][t2][p1][pp1] = ans % MOD;


                    }
                }
            }
        }
    }
}

int main() {
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);tt
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    FastIO;

    cin >> n;
    FOR(i, 0, tot_ch - 1) {
        cin >> sz[i];
    }

    MEM(dp1, -1);MEM(dp2, -1);
    MEM(dp3, -1);


    /// taking all
    LL ans = f1(0);

//    cout << ans << endl;

    /// removing those which violates our size
    FOR(i, 0, tot_ch - 1) {
        LL ss = 0;
        FOR(j, sz[i] + 1, n) {
            ss = sum(ss, f2(0, j, 0, 0));
        }
        ans = sub(ans, ss);
    }
//    cout << ans << endl;

    /// adding two string which violates our size (inclusion-exclusion)
    f3();

//    cout << "finished dp3" << endl;

    FOR(i1, 0, tot_ch - 1) {
        FOR(i2, i1 + 1, tot_ch - 1) {
            LL ss = 0;
            FOR(j1, sz[i1] + 1, n) {
                FOR(j2, sz[i2] + 1, n) {
                    ss = sum(ss, dp3[0][j1][j2][0][0]);
                }
            }
            ans = sum(ans, ss);
        }
    }

    /**
    adding three string which violates our size (inclusion-exclusion)
    don't bother because size of one string is greater than n/3.
    it's not possible to have three strings with size greater than n/3
    n/3 + n/3 + n/3 + 3 > n
    */
    cout << ans << "\n";


    return 0;
}
/**
*/
