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;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
 
#define F first
#define S second
 
const int MOD = 998244353;//1e9 + 7;//XXX
const int C = 26;//XXX
 
void add(int &x, int y){
	x += y;
	while (x >= MOD) x -= MOD;
	while (x < 0) x += MOD;
}
 
int fix(int x){
	while (x >= MOD) x -= MOD;
	while (x < 0) x += MOD;
	return x;
}
 
int pw(int a, int b){
	int ret = 1;
	while (b){
		if (b & 1)
			ret = 1ll*ret*a%MOD;
		b >>= 1;
		a = 1ll*a*a%MOD;
	}
	return ret;
}

int mul(int a, int b) {
	return (ll) a * b % MOD;
}

#define FOR(i,n) for(int i = 0; i < int(n); i++) 
const int MAXN = 400 + 10;
int n, cnt[C];

int dp1[2][MAXN][2][2]; 
// dp1[prefix][count A][2nd last equal to A][last equal to A] = #ways

int dp2[2][MAXN][MAXN][3][3];
// dp2[prefix][count A][count B][2nd last equal to A or B or neither][last equal to A or B or neither] = #ways

void solve() {
	cin >> n;
	FOR(i, 26) cin >> cnt[i];
	
	int z = 0;
	dp1[z][0][0][0] = 1;
	
	FOR(i,n) {
		memset(dp1[z^1], 0, sizeof(dp1[z^1]));
		FOR(j,n)FOR(k,2) {
			add(dp1[z^1][j][k][0], mul(C - 2 + (i < 2), dp1[z][j][0][k])); // place not A at end with not A at 2nd last
			add(dp1[z^1][j][k][0], mul(C - 1, dp1[z][j][1][k])); // place not A at end with A at 2nd last
			
			add(dp1[z^1][j+1][k][1], dp1[z][j][0][k]); // place A at end
		}
		z ^= 1;
	}
	
	z=0;
	dp2[z][0][0][0][0] = 1;
	FOR(i, n) {
		memset(dp2[z^1], 0, sizeof(dp2[z^1]));
		
		FOR(j, n)FOR(k, n)FOR(last, 3) {
			add(dp2[z^1][j][k][last][0], mul(C - 3 + (i < 2), dp2[z][j][k][0][last])); // place not, A, B, at end with not A, B at 2nd last
			add(dp2[z^1][j][k][last][0], mul(C - 2, dp2[z][j][k][1][last])); // place not A, B at end with A at 2nd last
			add(dp2[z^1][j][k][last][0], mul(C - 2, dp2[z][j][k][2][last])); // place not A, B at end with B at 2nd last
		
			add(dp2[z^1][j+1][k][last][1], dp2[z][j][k][0][last]); // place A
			add(dp2[z^1][j+1][k][last][1], dp2[z][j][k][2][last]);
			
			add(dp2[z^1][j][k+1][last][2], dp2[z][j][k][0][last]); // place B
			add(dp2[z^1][j][k+1][last][2], dp2[z][j][k][1][last]);
		}
		
		z ^= 1;
	}
	
	int ans = mul(26*26, pw(25, n-2)); // all ways, dont care about counts
	for(int i = 0; i < C; i++) {
		for(int j = cnt[i]+1; j <= n; j++) {
			FOR(a,2)FOR(b,2) {
				add(ans, -dp1[z][j][a][b]);
			}
		}
	}
	FOR(i,C)for(int j = i+1; j < C; j++) {
		for(int a = cnt[i]+1; a <= n; a++) {
			for(int b = cnt[j]+1; b <= n; b++) {
				FOR(c,3)FOR(d,3) {
					add(ans, dp2[z][a][b][c][d]);
				}
			}
		}
	}
	cout << ans << "\n";
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//cout << fixed << setprecision(6);
	
	int te = 1;	
	//cin >> te;
	for (int w = 1; w <= te; w++){
		//cout << "Case #" << w << ": ";
		solve();
	}
	return 0;
}