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:
// problem: G
#include <bits/stdc++.h>
using namespace std;

#define mk make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

template<typename T> inline void ckmax(T& x, T y) { x = (y > x ? y : x); }
template<typename T> inline void ckmin(T& x, T y) { x = (y < x ? y : x); }

const int MAXN = 400;
const int MOD = 998244353;

inline int mod1(int x) { return x < MOD ? x : x - MOD; }
inline int mod2(int x) { return x < 0 ? x + MOD : x; }
inline void add(int &x, int y) { x = mod1(x + y); }
inline void sub(int &x, int y) { x = mod2(x - y); }
inline int pow_mod(int x, int i) {
	int y = 1;
	while (i) {
		if (i & 1) y = (ll)y * x % MOD;
		x = (ll)x * x % MOD;
		i >>= 1;
	}
	return y;
}


int n;
int a[26];

int L1, L2;

namespace Calc1 {

int f[2][MAXN + 5][2];
int g[2][MAXN + 5][2];

int dp[MAXN + 5];

void init() {
	f[1][0][0] = 25;
	f[1][1][1] = 1;
	for (int i = 2; i <= L1; ++i) {
		int cur = (i & 1);
		int lst = (cur ^ 1);
		
		for (int j = 0; j <= i; ++j) f[cur][j][0] = f[cur][j][1] = 0;
		
		for (int j = 0; j <= i; ++j) {
			
			if (j) {
				add(f[cur][j][1], f[lst][j - 1][0]);
			}
			
			add(f[cur][j][0], (ll)f[lst][j][1] * 25 % MOD);
			add(f[cur][j][0], (ll)f[lst][j][0] * 24 % MOD);
		}
	}
	
	g[1][0][0] = 25;
	g[1][1][1] = 1;
	for (int i = 2; i <= L2; ++i) {
		int cur = (i & 1);
		int lst = (cur ^ 1);
		
		for (int j = 0; j <= i; ++j) g[cur][j][0] = g[cur][j][1] = 0;
		
		for (int j = 0; j <= i; ++j) {
			
			if (j) {
				add(g[cur][j][1], g[lst][j - 1][0]);
			}
			
			add(g[cur][j][0], (ll)g[lst][j][1] * 25 % MOD);
			add(g[cur][j][0], (ll)g[lst][j][0] * 24 % MOD);
		}
	}
	
	for (int i = 0; i <= L1; ++i) {
		int ff = mod1(f[L1 & 1][i][0] + f[L1 & 1][i][1]);
		for (int j = 0; j <= L2; ++j) {
			int gg = mod1(g[L2 & 1][j][0] + g[L2 & 1][j][1]);
			add(dp[i + j], (ll)ff * gg % MOD);
		}
	}
	
}

int calc(int c) {
	int res = 0;
	for (int i = a[c] + 1; i <= n; ++i) {
		add(res, dp[i]);
	}
	return res;
}
} // namespace Calc1


namespace Calc2 {


int f[2][MAXN + 5][MAXN + 5][3];
int g[2][MAXN + 5][MAXN + 5][3];

int dp[MAXN + 5][MAXN + 5];

void init() {
	f[1][0][0][0] = 24;
	f[1][1][0][1] = 1;
	f[1][0][1][2] = 1;
	
	for (int i = 2; i <= L1; ++i) {
		int cur = (i & 1);
		int lst = (cur ^ 1);
		
		for (int j = 0; j <= i; ++j) {
			for (int k = 0; k <= i; ++k) {
				f[cur][j][k][0] = f[cur][j][k][1] = f[cur][j][k][2] = 0;
			}
		}
		
		for (int j = 0; j <= i; ++j) {
			for (int k = 0; j + k <= i; ++k) {
				if (j) {
					add(f[cur][j][k][1], f[lst][j - 1][k][0]);
					add(f[cur][j][k][1], f[lst][j - 1][k][2]);
				}
				if (k) {
					add(f[cur][j][k][2], f[lst][j][k - 1][0]);
					add(f[cur][j][k][2], f[lst][j][k - 1][1]);
				}
				
				add(f[cur][j][k][0], (ll)f[lst][j][k][0] * 23 % MOD);
				add(f[cur][j][k][0], (ll)f[lst][j][k][1] * 24 % MOD);
				add(f[cur][j][k][0], (ll)f[lst][j][k][2] * 24 % MOD);
			}
		}
	}
	
	g[1][0][0][0] = 24;
	g[1][1][0][1] = 1;
	g[1][0][1][2] = 1;
	
	for (int i = 2; i <= L2; ++i) {
		int cur = (i & 1);
		int lst = (cur ^ 1);
		
		for (int j = 0; j <= i; ++j) {
			for (int k = 0; k <= i; ++k) {
				g[cur][j][k][0] = g[cur][j][k][1] = g[cur][j][k][2] = 0;
			}
		}
		
		for (int j = 0; j <= i; ++j) {
			for (int k = 0; j + k <= i; ++k) {
				if (j) {
					add(g[cur][j][k][1], g[lst][j - 1][k][0]);
					add(g[cur][j][k][1], g[lst][j - 1][k][2]);
				}
				if (k) {
					add(g[cur][j][k][2], g[lst][j][k - 1][0]);
					add(g[cur][j][k][2], g[lst][j][k - 1][1]);
				}
				
				add(g[cur][j][k][0], (ll)g[lst][j][k][0] * 23 % MOD);
				add(g[cur][j][k][0], (ll)g[lst][j][k][1] * 24 % MOD);
				add(g[cur][j][k][0], (ll)g[lst][j][k][2] * 24 % MOD);
			}
		}
	}
	
	for (int i = 0; i <= L1; ++i) {
		for (int j = 0; i + j <= L1; ++j) {
			int ff = ((ll)f[L1 & 1][i][j][0] + f[L1 & 1][i][j][1] + f[L1 & 1][i][j][2]) % MOD;
			
			for (int k = 0; k <= L2; ++k) {
				for (int l = 0; k + l <= L2; ++l) {
					int gg = ((ll)g[L2 & 1][k][l][0] + g[L2 & 1][k][l][1] + g[L2 & 1][k][l][2]) % MOD;
					
					add(dp[i + k][j + l], (ll)ff * gg % MOD);
				}
			}
		}
	}
	
	
//	for (int i = 0; i <= n; ++i) for (int j = 0; j <= n; ++j) {
//		assert(dp[i][j] == dp[j][i]);
//	}
}

int calc(int c1, int c2) {
	
	int res = 0;
	
	for (int i = a[c1] + 1; i <= n; ++i) {
		for (int j = a[c2] + 1; j <= n; ++j) {
			add(res, dp[i][j]);
		}
	}
	
	return res;
}

} // namespace Calc2

int main() {
	cin >> n;
	for (int i = 0; i < 26; ++i) {
		cin >> a[i];
	}
	
	L1 = n / 2;
	L2 = n - L1;
	
	int ans = 26LL * pow_mod(25, L1 - 1) % MOD * 26LL % MOD * pow_mod(25, L2 - 1) % MOD;
	
	Calc1 :: init();
	for (int c = 0; c < 26; ++c) {
		sub(ans, Calc1 :: calc(c));
	}
	
	Calc2 :: init();
	for (int c1 = 0; c1 < 26; ++c1) {
		for (int c2 = c1 + 1; c2 < 26; ++c2) {
			add(ans, Calc2 :: calc(c1, c2));
		}
	}
	
	cout << ans << endl;
	
	return 0;
}