Problem: You have c_1 letters 'a', c_2 letters 'b', ..., c_{26} letters 'z'. You want to build a beautiful string of length n from them (obviously, you cannot use the i-th letter more than c_i times). Each c_i is greater than n/3.

A string is called beautiful if there are no palindromic contiguous substrings of odd length greater than 1 in it. For example, the string "abacaba" is not beautiful, it has several palindromic substrings of odd length greater than 1 (for example, "aca"). Another example: the string "abcaa" is beautiful.

Calculate the number of different strings you can build, and print the answer modulo 998244353.

Input

The first line contains one integer n (3 ≤ n ≤ 400).

The second line contains 26 integers c_1, c_2, ..., c_{26} (n/3 < c_i ≤ n).

Output

Print one integer — the number of strings you can build, taken modulo 998244353.

Examples

Input


4
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2


Output


422500


Input


3
2 2 2 2 2 2 3 3 3 2 2 2 2 2 2 3 3 3 2 2 3 2 2 3 2 2


Output


16900


Input


400
348 322 247 158 209 134 151 267 268 176 214 379 372 291 388 135 147 304 169 149 193 351 380 368 181 340


Output


287489790

Solution (in CPP):

Solution:
#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) % MOD;
//}

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

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


LL suba[4];
LL sub(LL a, LL b) {
    return (((a - b) % MOD) + MOD) % MOD;
}

int dp1[410];
LL f1(int pos) {
    if(pos == n) {
        return 1;
    }
    if(dp1[pos] != -1) {
        return dp1[pos];
    }
    if(pos <= 1) {
        return dp1[pos] = (tot_ch * f1(pos + 1)) % MOD;
    }
    return dp1[pos] = ((tot_ch- 1) * f1(pos + 1)) % MOD;
}

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

LL 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
        ans += (tot_ch - 1LL) * f2(pos + 1, taken, 0, ppos);
    }
    else {
        /// can place ch

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

        /// not placing ch
        LL gun = tot_ch - 2;
        if(pos <= 1) {
            gun = tot_ch - 1;
        }
        ans += gun * f2(pos + 1, taken, 0, ppos);
    }

    ans %= MOD;
    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 += dp3[pos2][t1][t2 - 1][2][p1];

                            /// placing others
                            ans += (tot_ch - 2LL) * dp3[pos2][t1][t2][0][p1];
                        }
                        else if(pp1 == 2) {
                            /// can't place ch2

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

                            /// placing others
                            ans += (tot_ch - 2LL) * dp3[pos2][t1][t2][0][p1];
                        }
                        else {
                            /// can place all

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

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

                            /// not placing ch1 and ch2
                            LL gun = tot_ch - 3;
                            if(pos <= 1) {
                                gun = tot_ch - 2;
                            }
                            /// placing others
                            ans += gun * dp3[pos2][t1][t2][0][p1];
                        }

                        ans %= MOD;
                        dp3[pos1][t1][t2][p1][pp1] = ans;


                    }
                }
            }
        }
    }
}

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(suba, -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;
}
/**
*/