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 LL long long
#define pa pair<int,int>
const int Maxn=410;
const int mod=998244353;
const int inf=2147483647;
const double pi=acos(-1.0);
int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
void inc(int&x,int y){x+=y;if(x>=mod)x-=mod;}
void dec(int&x,int y){x-=y;if(x<0)x+=mod;}
int Pow(int x,int y)
{
	if(!y)return 1;
	int t=Pow(x,y>>1);t=(LL)t*t%mod;
	if(y&1)t=(LL)t*x%mod;return t;
}
int n,m,c[26],ans=26*26,inv24,inv25,f[Maxn][Maxn][Maxn][3],s2[Maxn][Maxn],g[Maxn][Maxn][2],s1[Maxn];
void dp1()//0 x 1 other
{
	g[1][1][0]=1;g[1][0][1]=25;
	for(int i=2;i<=m;i++)
	for(int j=0;j<=(i+1)/2;j++)
	{
		if(j)g[i][j][0]=g[i-1][j-1][1];
		g[i][j][1]=(LL)g[i-1][j][0]*25ll%mod;
		inc(g[i][j][1],(LL)g[i-1][j][1]*24ll%mod);
	}
	int o=(m+1)/2;
	s1[o]=(g[m][o][0]+g[m][o][1])%mod;
	for(int i=o-1;i>=0;i--)s1[i]=s1[i+1],inc(s1[i],g[m][i][0]),inc(s1[i],g[m][i][1]);
}
void w1(int x)
{
	int p=n-m;
	for(int i=0;i<=min((p+1)/2,c[x]+1);i++)
	{
		int t=0;
		for(int k=0;k<2;k++)inc(t,g[p][i][k]);
		dec(ans,(LL)t*s1[c[x]+1-i]%mod);
	}
}
void dp2()//0 x 1 y 2 other
{
	f[1][1][0][0]=f[1][0][1][1]=1;f[1][0][0][2]=24;
	for(int i=2;i<=m;i++)
	for(int j=0;j<=(i+1)/2;j++)
	for(int k=0;k<=(i+1)/2;k++)
	{
		if(j)f[i][j][k][0]=(f[i-1][j-1][k][1]+f[i-1][j-1][k][2])%mod;
		if(k)f[i][j][k][1]=(f[i-1][j][k-1][0]+f[i-1][j][k-1][2])%mod;
		f[i][j][k][2]=(f[i-1][j][k][0]+f[i-1][j][k][1])%mod;
		f[i][j][k][2]=(LL)f[i][j][k][2]*24ll%mod;
		inc(f[i][j][k][2],(LL)f[i-1][j][k][2]*23ll%mod);
	}
	int o=(m+1)/2;
	for(int i=o;i>=0;i--)
	{
		s2[i][o]=0;
		for(int j=0;j<3;j++)inc(s2[i][o],f[m][i][o][j]);
		for(int j=o-1;j>=0;j--)
		{
			s2[i][j]=s2[i][j+1];
			for(int k=0;k<3;k++)inc(s2[i][j],f[m][i][j][k]);
		}
		if(i<o)
		{
			for(int j=0;j<=o;j++)inc(s2[i][j],s2[i+1][j]);
		}
	}
}
void w2(int x,int y)
{
	int p=n-m;
	for(int i=0;i<=min(c[x]+1,(p+1)/2);i++)
	for(int j=0;j<=min(c[y]+1,(p+1)/2)&&i+j<=p;j++)
	{
		int t=0;
		for(int k=0;k<3;k++)inc(t,f[p][i][j][k]);
		inc(ans,(LL)t*s2[c[x]+1-i][c[y]+1-j]%mod);
	}
}
int main()
{
	n=read();inv24=Pow(24,mod-2);inv25=Pow(25,mod-2);m=(n+1)/2;
	for(int i=0;i<26;i++)c[i]=read();
	for(int i=1;i<n-1;i++)ans=(LL)ans*25ll%mod;
	
//	printf("%d\n",ans);
	
	dp1();
	for(int i=0;i<26;i++)w1(i);
	
//	printf("%d\n",ans);
	
	dp2();
	for(int i=0;i<25;i++)
	for(int j=i+1;j<26;j++)
	w2(i,j);
	
	printf("%d",ans);
}