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>
#define LL long long
using namespace std;

const LL MD = 998244353;
const int ALP = 26;
const int MXN = 404;
int n;
int cnt[ALP];

LL dp[2][MXN][MXN][3][3];
// dp[i][cntA][cntB][2ndLast][Last]

LL result[MXN][MXN];
LL ps[MXN][MXN];


void buildDP()
{
    const int A = 0;
    const int B = 1;
    const int X = 2;  // Not A and B
    for(int i=0;i<3;i++) for(int j=0;j<3;j++)
    {
        int thisRound = 1;
        if(i == X) thisRound *= (ALP-2);
        if(j == X) thisRound *= (ALP-2);
        const int A_COUNT = (i == A) + (j == A);
        const int B_COUNT = (i == B) + (j == B);
        dp[1][A_COUNT][B_COUNT][i][j] = thisRound;
    }

    const int OLD = 1;
    const int CUR = 0;

    const int CAP = n/2 + 1;

    for(int t = 3; t <= n; t++)
    {
        for(int aCount = 0; aCount <= CAP; aCount++) for(int bCount = 0; bCount <= CAP; bCount++) for(int slast = 0; slast < 3; slast++)
        {
            dp[CUR][aCount][bCount][slast][A] = 0;
            if(aCount > 0)
            {
                dp[CUR][aCount][bCount][slast][A] = (dp[OLD][aCount-1][bCount][B][slast] + dp[OLD][aCount-1][bCount][X][slast]) % MD;
            }

            dp[CUR][aCount][bCount][slast][B] = 0;
            if(bCount > 0)
            {
                dp[CUR][aCount][bCount][slast][B] = (dp[OLD][aCount][bCount-1][A][slast] + dp[OLD][aCount][bCount-1][X][slast]) % MD;
            }

            dp[CUR][aCount][bCount][slast][X] = 0;
            dp[CUR][aCount][bCount][slast][X] += (ALP - 2) * dp[OLD][aCount][bCount][A][slast];
            dp[CUR][aCount][bCount][slast][X] += (ALP - 2) * dp[OLD][aCount][bCount][B][slast];
            dp[CUR][aCount][bCount][slast][X] += (ALP - 3) * dp[OLD][aCount][bCount][X][slast];
            dp[CUR][aCount][bCount][slast][X] %= MD;
        }

        // Update
        swap(dp[CUR],dp[OLD]);
    }

    // Build the final result
    for(int aCount = 0; aCount <= n; aCount++) for(int bCount = 0; bCount <= n; bCount++)
    {
        for(int i=0;i<3;i++) for(int j=0;j<3;j++) result[aCount][bCount] += dp[OLD][aCount][bCount][i][j];
        result[aCount][bCount] %= MD;
    }
}

LL getAnything()
{
    LL ret = 0;
    const int CAP = n/2 + 1;
    for(int i=0;i<=CAP;i++) for(int j=0;j<=CAP;j++) ret = (ret + result[i][j]) % MD;
    return ret;
}

LL getSingleViolation(int ca)
{
    LL ret = 0;
    const int CAP = n/2 + 1;
    for(int i=cnt[ca]+1;i<=CAP;i++) for(int j=0;j<=CAP;j++) ret = (ret + result[i][j]) % MD;
    return ret;
}

LL getDoubleViolation(int ca, int cb)
{
    LL ret = 0;
    const int CAP = n/2 + 1;
    for(int i=cnt[ca]+1;i<=CAP;i++) for(int j=cnt[cb]+1;j<=CAP;j++) ret = (ret + result[i][j]) % MD;
    return ret;
}



int main()
{
    // Read Input
    scanf("%d",&n);
    for(int i=0;i<ALP;i++) scanf("%d",&cnt[i]);
    // Dynamic Programming
    buildDP();

    LL add0 = getAnything();
    LL sub1 = 0;
    LL add2 = 0;
    for(int i=0;i<ALP;i++)
    {
        const LL thisSingle = getSingleViolation(i);
        sub1 = (sub1 + thisSingle) % MD;
        for(int j = i+1; j < ALP; j++)
        {
            const LL thisDouble = getDoubleViolation(i,j);
            add2 = (add2 + thisDouble) % MD;
        }
    }

    const LL ans = (add0 + add2 + MD - sub1) % MD;

    printf("%lld\n",ans);
    return 0;
}