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 <cstdio>
#include <algorithm>
using namespace std;
typedef long long LL;

const LL mod = 998244353;

LL ans , f[405][405][4] , g[2][405][405][9];
int c[305] , n;

void Add(LL &x , LL y) {x = (x + y) % mod;}
void Sub(LL &x , LL y) {x = (x - y + mod) % mod;}

int main() {
	scanf("%d" , &n);
	for (int i = 1; i <= 26; ++i) scanf("%d" , &c[i]);
	ans = 1;
	for (int i = 1; i <= n; ++i) ans = (ans * (26 - (i > 2))) % mod;
	f[1][0][0] = 25;
	f[1][1][1] = 1;
	// 0:00 1:10 2:01 3:11
	for (int i = 1; i < n; ++i) {
		for (int j = 0; j <= i; ++j) {
			Add(f[i + 1][j][0] , f[i][j][0] * (25 - (i > 1)) % mod + f[i][j][2] * 25 % mod);
			Add(f[i + 1][j + 1][1] , f[i][j][0]);
			Add(f[i + 1][j][2] , f[i][j][1] * (25 - (i > 1)) % mod + f[i][j][3] * 25 % mod);
			Add(f[i + 1][j + 1][3] , f[i][j][1]);
		}
	}
	g[1][0][0][0] = 24;
	g[1][1][0][1] = 1;
	g[1][0][1][2] = 1; 
	// 0:00 1:10 2:20 3:01 4:11 5:21 6:02 7:12 8:22
	for (int i = 1; i < n; ++i) {
		for (int j = 0; j <= i; ++j) {
			for (int k = 0; k + j <= i; ++k) {
				Add(g[(i + 1) & 1][j][k][0] , g[i & 1][j][k][0] * (24 - (i > 1)) % mod + g[i & 1][j][k][3] * 24 % mod + g[i & 1][j][k][6] * 24 % mod);
				Add(g[(i + 1) & 1][j + 1][k][1] , g[i & 1][j][k][0] + g[i & 1][j][k][6]);
				Add(g[(i + 1) & 1][j][k + 1][2] , g[i & 1][j][k][0] + g[i & 1][j][k][3]);
				Add(g[(i + 1) & 1][j][k][3] , g[i & 1][j][k][1] * (24 - (i > 1)) % mod + g[i & 1][j][k][4] * 24 % mod + g[i & 1][j][k][7] * 24 % mod);
				Add(g[(i + 1) & 1][j + 1][k][4] , g[i & 1][j][k][1] + g[i & 1][j][k][7]);
				Add(g[(i + 1) & 1][j][k + 1][5] , g[i & 1][j][k][1] + g[i & 1][j][k][4]);
				Add(g[(i + 1) & 1][j][k][6] , g[i & 1][j][k][2] * (24 - (i > 1)) % mod + g[i & 1][j][k][5] * 24 % mod + g[i & 1][j][k][8] * 24 % mod);
				Add(g[(i + 1) & 1][j + 1][k][7] , g[i & 1][j][k][2] + g[i & 1][j][k][8]);
				Add(g[(i + 1) & 1][j][k + 1][8] , g[i & 1][j][k][2] + g[i & 1][j][k][5]);
				g[i & 1][j][k][0] = g[i & 1][j][k][1] = g[i & 1][j][k][2] = g[i & 1][j][k][3] = g[i & 1][j][k][4] = g[i & 1][j][k][5] = g[i & 1][j][k][6] = g[i & 1][j][k][7] = g[i & 1][j][k][8] = 0;
				 
			}
		}
	}
	for (int i = 1; i <= 26; ++i) {
		for (int j = c[i] + 1; j <= n; ++j) {
			for (int w = 0; w <= 3; ++w) {
				Sub(ans , f[n][j][w]);
			}
		}
	}
	for (int i = 1; i <= 26; ++i) {
		for (int j = i + 1; j <= 26; ++j) {
			for (int p = c[i] + 1; p <= n; ++p) {
				for (int q = c[j] + 1; q <= n; ++q) {
					for (int w = 0; w <= 8; ++w) {
						Add(ans , g[n & 1][p][q][w]);
					}
				}
			}
		}
	}
	printf("%lld" , ans);
	return 0;
}