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 <cassert>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <utility>
#include <algorithm>
#include <iostream>
#include <sstream>
using namespace std;

#define SIZE(x) int((x).size())
#define REP(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
typedef long long I64;
typedef unsigned long long U64;
const double EPS = 1e-12;
const int INF = 999999999;
typedef vector<int> VI;
typedef vector<string> VS;
typedef pair<int,int> PII;

const int MOD=998244353;

int n;
int a[26];

int f[2][401][401][3][3];
PII fb[2];
PII fb2[2][401];
int id[2][401][401][3][3];

int g[2][401][2][2];

int Sum() {
    int f[401][2];
    f[0][0]=26*25;
    f[0][1]=26;
    for(int i=1;i<=n-2;i++) {
        f[i][0]=(I64(f[i-1][0])*24+I64(f[i-1][1])*25)%MOD;
        f[i][1]=f[i-1][0];
    }
    return ((I64)f[n-2][0] + (I64)f[n-2][1]) % MOD;
}

void ResetBound(int p) {
    fb[p]=make_pair(INF,-INF);
    for(int i=0;i<=n;i++) fb2[p][i]=make_pair(INF,-INF);
}

inline void Add(int p,int c0,int c1,int i,int j,int v,int cur_id) {
    int &res=f[p][c0][c1][i][j];
    if(id[p][c0][c1][i][j]!=cur_id) {
        id[p][c0][c1][i][j]=cur_id;
        res=0;
    }
    res=(res+v)%MOD;
    fb[p].first = min(fb[p].first, c0);
    fb[p].second = max(fb[p].second, c0);
    fb2[p][c0].first = min(fb2[p][c0].first, c1);
    fb2[p][c0].second = max(fb2[p][c0].second, c1);
}

void Solve() {
    scanf("%d",&n);
    int ans = Sum();
    // printf("%d\n",ans); 

    for(int i=0;i<26;i++) scanf("%d",&a[i]);
    int n3=n/3+1;
    if(n%3>0) n3++;

    int gcur=0;
    {
        memset(g[0],0,sizeof(g[0]));
        int left=n-2;
        for(int i=0;i<2;i++)
            for(int j=0;j<2;j++) {
                int d0=0;
                if(i==0) d0++;
                if(j==0) d0++;
                if(d0+left<n3) continue;

                int w=1;
                if(i==1 && j==1) w=25*25;
                else if(i==1 || j==1) w=25;
                g[gcur][d0][i][j]=w;
            }
        for(int left=n-3;left>=0;left--) {
            int next=1-gcur;
            memset(g[next],0,sizeof(g[next]));
            for(int c0=0;c0<=n;c0++) {
                for(int i=0;i<2;i++)
                    for(int j=0;j<2;j++) {
                        I64 w=g[gcur][c0][i][j];
                        if(w==0) continue;
                        for(int k=0;k<2;k++) {
                            if(k==0 && k==i) continue;
                            int d0=c0;
                            if(k==0) d0++;
                            if(d0+left<n3) continue;

                            int mul=1;
                            if(k==1) {
                                if(i==1) mul=24;
                                else mul=25;
                            }
                            g[next][d0][j][k]=(w*mul+g[next][d0][j][k])%MOD;
                        }
                    }
            }
            gcur=next;
        }
    }


    memset(id,-1,sizeof(id));
    int cur=0;
    {
        ResetBound(cur);
        int left=n-2;
        for(int i=0;i<3;i++)
            for(int j=0;j<3;j++) {
                int d0=0,d1=0;
                if(i==0) d0++;
                if(j==0) d0++;
                if(i==1) d1++;
                if(j==1) d1++;
                if(d0+d1+left<n3*2) continue;

                int w=1;
                if(i==2 && j==2) {
                    w=24*24;
                } else if(i==2 || j==2) {
                    w=24;
                }
                Add(cur,d0,d1,i,j,w,left);
            }
    }

    for(int left=n-3;left>=0;left--) {
        int next=1-cur;
        ResetBound(next);
        for(int c0=fb[cur].first;c0<=fb[cur].second;c0++) {
            for(int c1=fb2[cur][c0].first;c1<=fb2[cur][c0].second;c1++) {
            for(int i=0;i<3;i++)
                for(int j=0;j<3;j++) {
                    if(id[cur][c0][c1][i][j]!=left+1) continue;
                    I64 w=f[cur][c0][c1][i][j];
                    if(w==0) continue;
                    for(int k=0;k<3;k++) {
                        if(k<2 && k==i) continue;
                        int d0=c0,d1=c1;
                        if(k==0) d0++;
                        if(k==1) d1++;
                        if(d0+d1+left<n3*2) continue;

                        int mul=1;
                        if(k==2) {
                            if(i==2) mul=23;
                            else mul=24;
                        }
                        Add(next,d0,d1,j,k,(w*mul)%MOD,left);
                    }
                }
            }
        }
        cur=next;
    }

    for(int v0=0;v0<26;v0++)
        for(int c0=a[v0]+1;c0<=n;c0++) {
            for(int i=0;i<2;i++)
                for(int j=0;j<2;j++) {
                    ans-=g[gcur][c0][i][j];
                    ans%=MOD;
                }
            for(int v1=v0+1;v1<26;v1++) {
                for(int c1=a[v1]+1;c0+c1<=n;c1++) {
                    for(int i=0;i<3;i++)
                        for(int j=0;j<3;j++) {
                            if(id[cur][c0][c1][i][j]!=0) continue;
                            ans+=f[cur][c0][c1][i][j];
                            ans%=MOD;
                        }
                }
            }
        }
    if(ans<0) ans+=MOD;
    printf("%d\n",ans);
}

int main() {
    Solve();

    return 0;
}