/**
 *    Author:  Oak_limy
 *    Created: 2021-02-26 23:42:28
 *    Wish you and me a better future.
**/
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define YES puts("YES")
#define NO puts("NO")

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline int readint() {
	int f=1,x=0; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch<='9'&&ch>='0') x=x*10+ch-'0',ch=getchar();
    return f*x;
}
inline ll readll() {
	ll f=1,x=0; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch<='9'&&ch>='0') x=x*10+ch-'0',ch=getchar();
    return f*x;
}
void fl(string name){
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
const ll MAXN=410;
const ll mod=998244353;
ll n,dp[2][MAXN][MAXN][3][3],sum[MAXN][MAXN],c[26];
//x用了i次，y用了j次，k表示倒数第二位是否为x/y，l表示倒数第一位是否为x/y 
//0:不是x或y，1:是x，2:是y 
void add(ll &x,ll y){
	x+=y;
	if(x>=mod)x-=mod;
}
void sub(ll &x,ll y){
	x-=y;
	if(x<0)x+=mod;
}
int main(){
	n=readll();
	for(int i=0;i<26;i++)c[i]=readll();
	dp[0][0][0][0][0]=1;
	for(int i=1;i<=n;i++){
		ll cur=i&1,lst=cur^1;
		for(int j=0;j<=n;j++){
			for(int k=0;k<=n;k++){
				for(int x=0;x<=2;x++){
					for(int y=0;y<=2;y++){
						dp[cur][j][k][x][y]=0;
					}
				}
			}
		}
		for(int j=0;j<=n;j++){
			for(int k=0;k<=n;k++){
				for(int x=0;x<=2;x++){
					for(int y=0;y<=2;y++){
						if(dp[lst][j][k][x][y]){
							if(i>2&&x==0)
								add(dp[cur][j][k][y][0],dp[lst][j][k][x][y]*23%mod);
							else 
								add(dp[cur][j][k][y][0],dp[lst][j][k][x][y]*24%mod);
							if(x!=1)
								add(dp[cur][j+1][k][y][1],dp[lst][j][k][x][y]);
							if(x!=2)
								add(dp[cur][j][k+1][y][2],dp[lst][j][k][x][y]);
						}
					}
				}
			}
		}
	}
	ll ans=powmod(26,2,mod)*powmod(25,n-2,mod)%mod;
	for(int j=0;j<=n;j++){
		for(int k=0;k<=n;k++){
			for(int x=0;x<=2;x++){
				for(int y=0;y<=2;y++){
					if(dp[n&1][j][k][x][y])
						add(sum[j][k],dp[n&1][j][k][x][y]);
				}
			}
		}
	}
	for(int j=n;j>=0;j--){
		for(int k=n;k>=0;k--){	
			add(sum[j][k],sum[j+1][k]);
		}
	}
	for(int j=n;j>=0;j--){
		for(int k=n;k>=0;k--){
			add(sum[j][k],sum[j][k+1]);
		}
	}
	for(int i=0;i<26;i++)sub(ans,sum[c[i]+1][0]);
	for(int i=0;i<26;i++){
		for(int j=i+1;j<26;j++){
			add(ans,sum[c[i]+1][c[j]+1]);
		}
	}
	printf("%lld\n",ans);
	return 0;
}
/* stuff to remember
	* int overflow, array bounds
	* special cases (n=1? n=0?)
	* do something instead of nothing and stay organized
	* USE STATIC ARRAYS
	* DEFINING ARRAYS BEFORE main()
	* DO NOT DEFINE ARRAYS IN main()
	* USE INT INSTEAD OF LL,NOTICE THE MLE
*/
### Prompt

Please formulate a CPP solution to the following 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

### Response

```cpp
/**
 *    Author:  Oak_limy
 *    Created: 2021-02-26 23:42:28
 *    Wish you and me a better future.
**/
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define YES puts("YES")
#define NO puts("NO")

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline int readint() {
	int f=1,x=0; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch<='9'&&ch>='0') x=x*10+ch-'0',ch=getchar();
    return f*x;
}
inline ll readll() {
	ll f=1,x=0; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch<='9'&&ch>='0') x=x*10+ch-'0',ch=getchar();
    return f*x;
}
void fl(string name){
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
const ll MAXN=410;
const ll mod=998244353;
ll n,dp[2][MAXN][MAXN][3][3],sum[MAXN][MAXN],c[26];
//x用了i次，y用了j次，k表示倒数第二位是否为x/y，l表示倒数第一位是否为x/y 
//0:不是x或y，1:是x，2:是y 
void add(ll &x,ll y){
	x+=y;
	if(x>=mod)x-=mod;
}
void sub(ll &x,ll y){
	x-=y;
	if(x<0)x+=mod;
}
int main(){
	n=readll();
	for(int i=0;i<26;i++)c[i]=readll();
	dp[0][0][0][0][0]=1;
	for(int i=1;i<=n;i++){
		ll cur=i&1,lst=cur^1;
		for(int j=0;j<=n;j++){
			for(int k=0;k<=n;k++){
				for(int x=0;x<=2;x++){
					for(int y=0;y<=2;y++){
						dp[cur][j][k][x][y]=0;
					}
				}
			}
		}
		for(int j=0;j<=n;j++){
			for(int k=0;k<=n;k++){
				for(int x=0;x<=2;x++){
					for(int y=0;y<=2;y++){
						if(dp[lst][j][k][x][y]){
							if(i>2&&x==0)
								add(dp[cur][j][k][y][0],dp[lst][j][k][x][y]*23%mod);
							else 
								add(dp[cur][j][k][y][0],dp[lst][j][k][x][y]*24%mod);
							if(x!=1)
								add(dp[cur][j+1][k][y][1],dp[lst][j][k][x][y]);
							if(x!=2)
								add(dp[cur][j][k+1][y][2],dp[lst][j][k][x][y]);
						}
					}
				}
			}
		}
	}
	ll ans=powmod(26,2,mod)*powmod(25,n-2,mod)%mod;
	for(int j=0;j<=n;j++){
		for(int k=0;k<=n;k++){
			for(int x=0;x<=2;x++){
				for(int y=0;y<=2;y++){
					if(dp[n&1][j][k][x][y])
						add(sum[j][k],dp[n&1][j][k][x][y]);
				}
			}
		}
	}
	for(int j=n;j>=0;j--){
		for(int k=n;k>=0;k--){	
			add(sum[j][k],sum[j+1][k]);
		}
	}
	for(int j=n;j>=0;j--){
		for(int k=n;k>=0;k--){
			add(sum[j][k],sum[j][k+1]);
		}
	}
	for(int i=0;i<26;i++)sub(ans,sum[c[i]+1][0]);
	for(int i=0;i<26;i++){
		for(int j=i+1;j<26;j++){
			add(ans,sum[c[i]+1][c[j]+1]);
		}
	}
	printf("%lld\n",ans);
	return 0;
}
/* stuff to remember
	* int overflow, array bounds
	* special cases (n=1? n=0?)
	* do something instead of nothing and stay organized
	* USE STATIC ARRAYS
	* DEFINING ARRAYS BEFORE main()
	* DO NOT DEFINE ARRAYS IN main()
	* USE INT INSTEAD OF LL,NOTICE THE MLE
*/
```