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>
#define LL long long 
#define fi first
#define se second
#define mp make_pair
#define PLL pair<LL, LL>
#define PIL pair<int, LL>
#define PII pair<int, int>

using namespace std;

const int N = 407;
const int mod = 998244353;

int n, c[27];
int dp[2][N][N][3][3];
int f[N][N][2][2];

inline void add(int& a, int b) {
	a += b;
	if (a >= mod) a -= mod;
}

inline void sub(int& a, int b) {
	a -= b;
	if (a < 0) a += mod;
}

void clear_dp(int cur, int n) {
	for (int n1 = 0; n1 <= n; n1++) {
		for (int n2 = 0; n1 + n2 <= n; n2++) {
			for (int c1 = 0; c1 < 3; c1++) {
				for (int c2 = 0; c2 < 3; c2++) {
					dp[cur][n1][n2][c1][c2] = 0;
				}
			}
		}
	}
}

void solve() {
	scanf("%d", &n);
	for (int i = 1; i <= 26; i++) scanf("%d", &c[i]);
	int cur = 0, pre = 1;
	dp[cur][0][0][0][0] = 1;
	for (int i = 0; i < n; i++) {
		swap(cur, pre);
		clear_dp(cur, i + 1);
		for (int n1 = 0; n1 <= i; n1++) {
			for (int n2 = 0; n1 + n2 <= i; n2++) {
				for (int c1 = 0; c1 < 3; c1++) {
					for (int c2 = 0; c2 < 3; c2++) {
						if (!dp[pre][n1][n2][c1][c2]) continue;
						int v = dp[pre][n1][n2][c1][c2];
						int base = 24 - (i > 1 && !c1);
						for (int c3 = 0; c3 < 3; c3++) {
							if (c3 && c3 == c1) continue;
							if (c3 == 1) add(dp[cur][n1 + 1][n2][c2][c3], v);
							else if (c3 == 2) add(dp[cur][n1][n2 + 1][c2][c3], v);
							else if (c3 == 0) add(dp[cur][n1][n2][c2][c3], 1LL * base * v % mod);
						}
					}
				}
			}
		}
	}
	f[0][0][0][0] = 1;
	for (int i = 0; i < n; i++) {
		for (int n1 = 0; n1 <= i; n1++) {
			for (int c1 = 0; c1 < 2; c1++) {
				for (int c2 = 0; c2 < 2; c2++) {
					if (!f[i][n1][c1][c2]) continue;
					int v = f[i][n1][c1][c2];
					int base = 25 - (i > 1 && !c1);
					for (int c3 = 0; c3 < 2; c3++) {
						if (c3 && c3 == c1) continue;
						if (c3 == 1) add(f[i + 1][n1 + 1][c2][c3], v);
						else add(f[i + 1][n1][c2][c3], 1LL * base * v % mod);
					}
				}
			}
		}
	}
	int ans = 26 * 26;
	for (int i = 3; i <= n; i++) ans = 1LL * ans * 25 % mod;
	// sub one over
	for (int i = 1; i <= 26; i++) {
		int value = 0;
		for (int a = c[i] + 1; a <= n; a++) {
			for (int b = 0; b < 2; b++) {
				for (int c = 0; c < 2; c++) {
					// printf("i: %d  a: %d  b: %d  c: %d   %d\n", i, a, b, c, f[n][a][b][c]);
					add(value, f[n][a][b][c]);
				}
			}
		}
		sub(ans, value);
	}
	// add two over
	for (int i = 1; i <= 26; i++) {
		for(int j = i + 1; j <= 26; j++) {
			int value = 0;
			int up1 = c[i], up2 = c[j];
			for (int a = up1 + 1; a <= n; a++) {
				for (int b = up2 + 1; a + b <= n && b <= n; b++) {
					int mn = min(a, b);
					int mx = max(a, b);
					for (int c = 0; c < 3; c++) {
						for (int d = 0; d < 3; d++) {
							add(value, dp[cur][a][b][c][d]);
						}
					}
				}
			}
			add(ans, value);
		}
	}
	printf("%d\n", ans);
}

int main() {
	int NT = 1;
	while(NT--) solve();
	return 0;
}