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:

#pragma GCC optimize(3)
#pragma GCC target("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")

#include<iostream>
#include<cstring>
#include<cstdio>
#include<climits>
#include<algorithm>
#include<queue>
#include<vector>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define int long long
#define mod 998244353
using namespace std;
inline int read(){
	int f=1,ans=0; char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
	return f*ans;
}
const int MAXN=411;
int f[2][MAXN][MAXN][3][3],N,A[27],g[MAXN][MAXN];
signed main(){
	//freopen("6.in","r",stdin);
	N=read(); for(int i=1;i<=26;i++) A[i]=read();
	int cur=0;
	f[cur][0][0][0][0]=24*24; 
	f[cur][1][0][0][1]=f[cur][1][0][1][0]=f[cur][0][1][2][0]=f[cur][0][1][0][2]=24;
	f[cur][1][1][1][2]=f[cur][1][1][2][1]=1;
	f[cur][2][0][1][1]=f[cur][0][2][2][2]=1;
	for(int i=2;i<N;i++){
		memset(f[cur^1],0,sizeof(f[cur^1])),cur^=1;
		for(int j=0;j<=N;j++)
			for(int k=0;k<=N;k++){
				if(i&1){
					for(int p=0;p<=2;p++){
						f[cur][j][k][p][0]+=23*f[cur^1][j][k][p][0]; f[cur][j][k][p][0]%=mod;
						f[cur][j+1][k][p][1]+=f[cur^1][j][k][p][0]; f[cur][j+1][k][p][1]%=mod;
						f[cur][j][k+1][p][2]+=f[cur^1][j][k][p][0]; f[cur][j][k+1][p][2]%=mod;
						f[cur][j][k][p][0]+=24*f[cur^1][j][k][p][1]; f[cur][j][k][p][0]%=mod;
						f[cur][j][k+1][p][2]+=f[cur^1][j][k][p][1]; f[cur][j][k+1][p][2]%=mod;
						f[cur][j][k][p][0]+=24*f[cur^1][j][k][p][2]; f[cur][j][k][p][0]%=mod;
						f[cur][j+1][k][p][1]+=f[cur^1][j][k][p][2]; f[cur][j+1][k][p][1]%=mod;
					}
				}else{
					for(int p=0;p<=2;p++){
						f[cur][j][k][0][p]+=23*f[cur^1][j][k][0][p]; f[cur][j][k][0][p]%=mod;
						f[cur][j+1][k][1][p]+=f[cur^1][j][k][0][p]; f[cur][j+1][k][1][p]%=mod;
						f[cur][j][k+1][2][p]+=f[cur^1][j][k][0][p]; f[cur][j][k+1][2][p]%=mod;
						f[cur][j][k][0][p]+=24*f[cur^1][j][k][1][p]; f[cur][j][k][0][p]%=mod;
						f[cur][j][k+1][2][p]+=f[cur^1][j][k][1][p]; f[cur][j][k+1][2][p]%=mod;
						f[cur][j][k][0][p]+=24*f[cur^1][j][k][2][p]; f[cur][j][k][0][p]%=mod;
						f[cur][j+1][k][1][p]+=f[cur^1][j][k][2][p]; f[cur][j+1][k][1][p]%=mod;
					}
				}
			}
	}
	for(int i=0;i<=N;i++) for(int j=0;j<=N;j++) for(int p1=0;p1<=2;p1++) for(int p2=0;p2<=2;p2++) g[i][j]+=f[cur][i][j][p1][p2],g[i][j]%=mod;
	for(int i=N;i>=0;i--) for(int j=N;j>=0;j--) g[i][j]+=g[i+1][j]+g[i][j+1]-g[i+1][j+1],g[i][j]=((g[i][j]%mod)+mod)%mod;
	int Ans=g[0][0];
	for(int i=1;i<=26;i++) Ans-=g[A[i]+1][0],Ans=((Ans%mod)+mod)%mod;
	for(int i=1;i<=26;i++) for(int j=i+1;j<=26;j++) Ans+=g[A[i]+1][A[j]+1],Ans=((Ans%mod)+mod)%mod;
	printf("%lld\n",Ans); return 0;
}