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:
/*
Nahid Hossain
Jahangirnagar University
Roll:54
*/
#include<bits/stdc++.h>
#include<string.h>
#define ll long long
#define pf printf
#define sf scanf
#define ff first
#define ss second
#define clr clear()
#define sz size()
#define pb push_back
#define mk make_pair
#define pi acos(-1)
#define inf 20000000000000000
#define mod 998244353
#define ull unsigned long long int
#define f(i,k,n) for(i=k;i<n;i++)
#define fr(i,n,k) for(i=n;i>=k;i--)
#define ent(a) scanf("%lld",&a)
#define ent2(a,b) scanf("%lld%lld",&a,&b)
#define ent3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define mem(a) memset(a,0,sizeof(a))
#define vec(v,s) vector<ll>v[s]
#define arr(a,s) ll a[s];
//knight and king//
int dr[]= {2,2,-2,-2,1,-1,1,-1};
int dc[]= {1,-1,1,-1,2,2,-2,-2};
int dr1[]= {0,0,1,1,1,-1,-1,-1};
int dc1[]= {1,-1,1,0,-1,0,1,-1};
int dr2[]= {0,0,1,-1};
int dc2[]= {1,-1,0,0};
////////////////////////////
using namespace std;
#define ma 405
ll dp[ma][28][28],a[ma],n;
ll cal(ll x,ll y,ll z)
{
    if(x==0)return 1;
    ll &r=dp[x][y][z];
    if(r!=-1)return r;
    r=0;
    for(ll i=1;i<=26;i++)
    {
        if(i!=z)
        {
            r+=cal(x-1,i,y);
            r%=mod;
        }
    }
    return r;
}

int dp1[402][202][202][4][4],b[500][500];

ll cal1(ll x,ll y,ll z,ll k,ll k1)
{
    if(y<0||z<0)return 0;
    if(x==0)return (y==0&&z==0);
    int &r=dp1[x][y][z][k][k1];
    if(r!=-1)return r;
    r=0;
    if(k1!=1)
    {
        ll r1=cal1(x-1,y-1,z,1,k);
        r+=r1;r%=mod;
    }
    if(k1!=2)
    {
        ll r1=cal1(x-1,y,z-1,2,k);
        r+=r1;r%=mod;
    }
    ll cn;
    if(k1==3)cn=23;
    else cn=24;
    ll r1=cal1(x-1,y,z,3,k)*cn;
    r1%=mod;
    r+=r1;
    r%=mod;
    return r;

}

int dp2[402][402][3][3],c[ma];


ll cal2(ll x,ll y,ll k,ll k1)
{
    if(y<0)return 0;
    if(x==0)return (y==0);
    int &r=dp2[x][y][k][k1];
    if(r!=-1)return r;
    r=0;
    if(k1!=1)
    {
        ll r1=cal2(x-1,y-1,1,k);
        r+=r1;
        r%=mod;
    }
    ll cn;
    if(k1==2)cn=24;
    else cn=25;
    ll r1=cal2(x-1,y,2,k)*cn;
    r1%=mod;
    r+=r1;
    r%=mod;
    return r;
}


ll get(ll x,ll n)
{
    ll i,j,s=0,s1=0,k,m=(n+1)/2+1;
    for(i=a[x]+1;i<=m;i++)
    {
        s1+=c[i];
        s1%=mod;
        for(j=1;j<=26;j++)
        {
            if(j==x)continue;
            for(k=a[j]+1;k<=m;k++)
            {
                s+=b[i][k];
                s%=mod;
            }
        }
    }
    ll p=(s1-s+mod)%mod;
    return p;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll tc,i,q,m1,x,y,j,k;
    while(cin>>n)
    {

        for(i=1;i<=26;i++)
        {
            cin>>a[i];
        }
        memset(dp,-1,sizeof(dp));
        memset(dp1,-1,sizeof(dp1));
        memset(dp2,-1,sizeof(dp2));
        ll ans=cal(n,0,0);
        ll m=(n+1)/2+1;
        for(i=1;i<=m;i++)
        {
            c[i]=cal2(n,i,0,0);
        }



        for(i=1;i<=m;i++)
        {
            for(j=1;j<=m;j++)
            {
                b[i][j]=cal1(n,i,j,0,0);
            }
        }

        ll ans1=0;


        for(i=1;i<=26;i++)
        {
            ans1+=get(i,n);
            ans1%=mod;
        }

        for(i=1;i<=26;i++)
        {
            for(j=i+1;j<=26;j++)
            {
                for(ll i1=a[i]+1;i1<=m;i1++)
                {
                    for(ll j1=a[j]+1;j1<=m;j1++)
                    {
                     ans1+=b[i1][j1];ans1%=mod;
                    }
                }
            }
        }


        cout<<(ans-ans1+mod)%mod<<endl;



    }
    return 0;
}