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 PII pair<int, int>
#define PLL pair<LL, LL>
#define all_of(v) (v).begin(), (v).end()
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define fi first
#define se second
const int MAXN = 401;
//const LL INF = (LL) 1e9 + 8763;
//const LL MOD = (LL) 1e9 + 7;
using namespace std;
const LL MOD = 998244353;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

LL n, cnt[26], dall[MAXN], dp1[MAXN][MAXN][2], dp2[2][MAXN][MAXN][3], have[MAXN];

void solve() {
	cin >> n;
	for (int i = 0; i < 26; i++) {
		cin >> cnt[i];
	}
	
	int a = n / 2, b = n - a;
	for (int i = 1; i <= n; i++) {
		have[i] = 1;
	}
	have[a] = have[n] = 0;
	
	// [pos][used 0][used 1][last]
	dall[1] = 1;
	dp1[1][1][0] = 1;
	dp1[1][0][1] = 1;
	dp2[1][0][0][2] = 1;
	dp2[1][0][1][1] = 1;
	dp2[1][1][0][0] = 1;
	
	// 2
	for (int i = 2; i <= n; i++) {
		for (int u0 = 0; u0 <= i; u0++) {
			for (int u1 = 0; u1 <= i; u1++) {
				for (int last = 0; last < 3; last++) {
					LL &now = dp2[i % 2][u0][u1][last];
					now = 0;
					if (last == 0 && u0 == 0) continue;
					if (last == 1 && u1 == 0) continue;
					if (!have[i - 1] || last != 0) {
						now = (now + dp2[(i - 1) % 2][u0 - (last == 0)][u1 - (last == 1)][0]) % MOD;
					}
					if (!have[i - 1] || last != 1) {
						now = (now + dp2[(i - 1) % 2][u0 - (last == 0)][u1 - (last == 1)][1]) % MOD;
					}
					LL coe = 23 + (!have[i - 1] || last != 2);
					now = (now + dp2[(i - 1) % 2][u0 - (last == 0)][u1 - (last == 1)][2] * coe) % MOD;
				}
			}
		}
	}
	// 1
	for (int i = 2; i <= n; i++) {
		for (int u0 = 0; u0 <= i; u0++) {
			for (int last = 0; last < 2; last++) {
				if (last == 0 && u0 == 0) continue;
				LL &now = dp1[i][u0][last];
				if (!have[i - 1] || last != 0) {
					now = (now + dp1[i - 1][u0 - (last == 0)][0]) % MOD;
				}
				LL coe = 24 + (!have[i - 1] || last != 1);
				now = (now + dp1[i - 1][u0 - (last == 0)][1] * coe) % MOD;
			}
		}
	}
	// 0
	for (int i = 2; i <= n; i++) {
		LL coe = 25 + !have[i - 1];
		dall[i] = (dall[i - 1] * coe) % MOD;
	}
	
	LL tot = dall[n] * 26 % MOD;
	for (int t0 = 0; t0 < 26; t0++) {
		for (int u0 = cnt[t0] + 1; u0 <= n; u0++) {
			tot = (tot - dp1[n][u0][0] - dp1[n][u0][1] * 25) % MOD;
		}
	}
	for (int t0 = 0; t0 < 26; t0++) {
		for (int t1 = t0 + 1; t1 < 26; t1++) {
			for (int u0 = cnt[t0] + 1; u0 <= n; u0++) {
				for (int u1 = cnt[t1] + 1; u1 <= n; u1++) {
					tot = (tot + dp2[n % 2][u0][u1][0] + dp2[n % 2][u0][u1][1] + dp2[n % 2][u0][u1][2] * 24) % MOD;
				}
			}
		}
	}
	
	cout << (tot % MOD + MOD) % MOD << '\n';
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);

	int tc = 1;
//	cin >> tc;
	for (int i = 1; i <= tc; i++) {
		solve();
	}

	return 0;
}