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;

long long n,c[26],dp1[402][270][2][2],dp2[3][270][270][3][3],ans,mod=998244353ll;

long long fastp(long long base,int exp){
	if(exp==0)return 1ll;
	long long tmp=fastp(base,exp/2);
	tmp=(tmp*tmp)%mod;
	
	if(exp%2==1)tmp*=base;
	return tmp%mod;
}

long long f1(int pos,int num,int last1,int last2){
	if(num<0)return 0;
	if(pos==n){
		if(num==0)return 1;
		else return 0;
	}
	if(dp1[pos][num][last1][last2]!=-1)return dp1[pos][num][last1][last2];

	long long res=0;
	
	if(pos<=1){
		res=f1(pos+1,num-1,last2,1)+f1(pos+1,num,last2,0)*25ll;
	}else if(last1==0){
		res=f1(pos+1,num-1,last2,1)+f1(pos+1,num,last2,0)*24ll;
	}else if(last1==1){
		res=f1(pos+1,num,last2,0)*25ll;
	}
	res%=mod;
	return dp1[pos][num][last1][last2]=res;
}

long long f2(int pos,int num1,int num2,int last1,int last2){
	if(pos==n){
		if(num1==0 && num2==0)return 1;
		else return 0;
	}
	
	long long res=0;
	
	if(pos<=1){
		if(num1>0)
		res+=dp2[(pos+1)%2][num1-1][num2][last2][1];
		
		if(num2>0)
		res+=dp2[(pos+1)%2][num1][num2-1][last2][2];
		
		res+=dp2[(pos+1)%2][num1][num2][last2][0]*24ll;
		
	}else if(last1==0){
		if(num1>0)
		res+=dp2[(pos+1)%2][num1-1][num2][last2][1];
		
		if(num2>0)
		res+=dp2[(pos+1)%2][num1][num2-1][last2][2];
		
		res+=dp2[(pos+1)%2][num1][num2][last2][0]*23ll;
	}else if(last1==1){		
		if(num2>0)
		res+=dp2[(pos+1)%2][num1][num2-1][last2][2];
		
		res+=dp2[(pos+1)%2][num1][num2][last2][0]*24ll;
	}else if(last1==2){
		if(num1>0)
		res+=dp2[(pos+1)%2][num1-1][num2][last2][1];
		
		res+=dp2[(pos+1)%2][num1][num2][last2][0]*24ll;
	}
	
	res%=mod;
	return res;
}

int main(){

	ios::sync_with_stdio(false);
	cin.tie(0);
	memset(dp1,-1,sizeof(dp1));
	
	cin>>n;
	for(int i=0;i<26;i++)cin>>c[i];
	
	ans=26*26*fastp(25,n-2);
	
	
	for(int i=0;i<270;i++){
		long long cont=0;
		for(int j=0;j<26;j++)if(i>c[j])cont++;
		
		ans-=(f1(0,i,0,0)*cont)%mod;
		ans%=mod;
	}
	
	for(int i=n;i>=0;i--){
		for(int j=0;j<270;j++){
			for(int z=0;z<270;z++){
				for(int x=0;x<3;x++){
					for(int y=0;y<3;y++){
						dp2[i%2][j][z][x][y]=f2(i,j,z,x,y);
					}
				}
			}
		}
	}
	
	for(int i=0;i<270;i++){
		for(int j=i;j<270;j++){
			long long cont=0;
			for(int z=0;z<26;z++){
				for(int x=0;x<26;x++){
					if(i!=j){
						if(z!=x && i>c[z] && j>c[x])cont++;
					}else{
						if(z<x && i>c[z] && j>c[x])cont++;
					}
				}
			}
			ans+=(dp2[0][i][j][0][0]*cont)%mod;
			ans%=mod;
		}
	}	

	cout<<(ans%mod+mod)%mod<<"\n";
	return 0;
}