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 <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <ctime>

using namespace std;

const int mod = 998244353;

int c[26];

int solve(int n) {
	int res = 26 * 26;
	for (int i = 2; i < n; ++i) {
		res = ((long long)(res) * 25) % mod;
	}
	return res;
}

const int maxN = 410;
int dp1[2][2][2][maxN];
int dpone[maxN];
int dptwo[maxN][maxN];

void solveone(int n) {
	if (n == 1) return;
	dp1[0][0][0][0] = 25 * 25;
	dp1[0][0][1][1] = 25;
	dp1[0][1][0][1] = 25;
	dp1[0][1][1][2] = 1;
	
	int u = 0, v = 1;
	if (n == 2) return;
	

	for (int i = 2; i < n; ++i) {
		memset(dp1[v], 0, sizeof(dp1[v]));
		for (int v1 = 0; v1 < 2; ++v1) {
			for (int v2 = 0; v2 < 2; ++v2) {
				for (int k = 0; k < 2; ++k) {
					int add = 0;
					if (k == 1) ++add;
					long long mul = 1;
					if (v1 == 0 && k == 0) mul = 24;
					else if (v1 == 1 && k == 0) mul = 25;
					else if (v1 == 1 && k == 1) mul = 0;
					for (int cnt = 0; cnt < 300; ++cnt) {
						dp1[v][v2][k][cnt + add] += (mul * dp1[u][v1][v2][cnt]) % mod;
						if (dp1[v][v2][k][cnt + add] >= mod) {
							dp1[v][v2][k][cnt + add] -= mod;
						}
					}
				}
			}
		}
		swap(u, v);
	}

	for (int i = 0; i < 300; ++i) {
		dpone[i] = 0;
		for (int v1 = 0; v1 < 2; ++v1) {
			for (int v2 = 0; v2 < 2; ++v2) {
				for (int cnt = i; cnt < 300; ++cnt) {
					dpone[i] += dp1[u][v1][v2][cnt];
					if (dpone[i] >= mod) {
						dpone[i] -= mod;
					}
				}
			}
		}
	}
}

int dp2[2][3][3][maxN][maxN];

void solvetwo(int n) {
	int u = 0, v = 1;
	for (int i = 0; i < 26; ++i) {
		for (int j = 0; j < 26; ++j) {
			int cntC = 0;
			if (i == 0) ++cntC;
			if (j == 0) ++cntC;

			int cntK = 0;
			if (i == 1) ++cntK;
			if (j == 1) ++cntK;

			int tx = 0, ty = 0;
			if (i == 0) tx = 1;
			if (i == 1) tx = 2;
			if (j == 0) ty = 1;
			if (j == 1) ty = 2;

			dp2[u][tx][ty][cntC][cntK] += 1;
		}
	}

	for (int i = 2; i < n; ++i) {
		memset(dp2[v], 0, sizeof(dp2[v]));

		for (int cnt1 = 0; cnt1 < 300; ++cnt1) {
			if (cnt1 > i + 1) break;
			for (int cnt2 = 0; cnt2 < 300; ++cnt2) {
				if (cnt1 + cnt2 > i + 1) break;
				for (int v1 = 0; v1 < 3; ++v1) {
					for (int v2 = 0; v2 < 3; ++v2) {
						for (int k = 0; k < 3; ++k) {
							int addC = 0, addK = 0;
							if (k == 1) ++addC;
							if (k == 2) ++addK;
							long long mul = 1;
							if (v1 == 0 && k == 0) mul = 23;
							else if (v1 != 0 && k == 0) mul = 24;
							else if (v1 == k && v1 != 0) mul = 0;
							dp2[v][v2][k][cnt1 + addC][cnt2 + addK] += (mul * dp2[u][v1][v2][cnt1][cnt2]) % mod;
							if (dp2[v][v2][k][cnt1 + addC][cnt2 + addK] >= mod) {
								dp2[v][v2][k][cnt1 + addC][cnt2 + addK] -= mod;
							}
						}
					}
				}

			}
		}

		swap(u, v);
	}

	for (int i = 299; i >= 0; --i) {
		for (int j = 299; j >= 0; --j) {
			dptwo[i][j] = 0;
			dptwo[i][j] += dptwo[i + 1][j]; dptwo[i][j] %= mod;
			dptwo[i][j] += dptwo[i][j + 1]; dptwo[i][j] %= mod;
			dptwo[i][j] -= dptwo[i + 1][j + 1]; dptwo[i][j] = (dptwo[i][j] % mod + mod) % mod;
			for (int v1 = 0; v1 < 3; ++v1) {
				for (int v2 = 0; v2 < 3; ++v2) {
					dptwo[i][j] += dp2[u][v1][v2][i][j];
					dptwo[i][j] %= mod;
				}
			}
		}
	}
}

void solve() {
	int n;
	cin >> n;
	if (n == 1) {
		cout << 26 << endl;
		return;
	}

	for (int i = 0; i < 26; ++i) {
		cin >> c[i];
	}

	long long noconstraint = solve(n);
	cerr << noconstraint << endl;
	solveone(n);
	solvetwo(n);

	for (int i = 0; i < 26; ++i) {
		if (c[i] > 290) continue;
		noconstraint -= dpone[c[i] + 1];
		noconstraint %= mod;
	}

	for (int i = 0; i < 26; ++i) {
		for (int j = i + 1; j < 26; ++j) {
			if (c[i] > 290 && c[j] > 290) continue;
			noconstraint += dptwo[c[i] + 1][c[j] + 1];
			noconstraint %= mod;
		}
	}
	noconstraint = (noconstraint + mod) % mod;
	cout << noconstraint << endl;
}

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int t;
	//cin >> t;
	t = 1;


	for (int tt = 0; tt < t; ++tt) {
		solve();
	}




	return 0;

}