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>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_p(x) cerr<<#x": "<<(x).first<<' '<<(x).second<<endl
#define dbg_v(x, n) {cerr<<#x"[]: ";for(long long _=0;_<n;++_)cerr<<(x)[_]<<' ';cerr<<endl;}
#define all(v) v.begin(), v.end()
#define fi first
#define se second
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

template<typename T1, typename T2>
ostream& operator <<(ostream &out, const pair<T1, T2> &item) {
	out << '(' << item.first << ", " << item.second << ')';
	return out;
}

template <typename T>
ostream& operator <<(ostream &out, const vector<T>& v) {
	for(const auto &item : v) out << item << ' ';
	return out;
}

const int A = 26;
const int N = 410;
const int MOD = 998244353;

int cnt[A];
int dp[2][N][2][2], dp2[2][N][N][3][3];

void add(int &x, ll y) { x = (x + y) % MOD; }
void sub(int &x, ll y) { x = (x - y) % MOD; if(x < 0) x += MOD; }

void precalc(int n) {
	dp[0][0][0][0] = 1;
	for(int i = 0; i < n; ++i) {
		memset(dp[(i + 1) & 1], 0, sizeof dp[(i + 1) & 1]);

		for(int j = 0; j <= i; ++j)
			for(int a = 0; a < 2; ++a)
				for(int b = 0; b < 2; ++b) {
					// chose a
					if(a == 0) add(dp[(i + 1) & 1][j + 1][b][1], dp[i & 1][j][a][b]);

					// chose !a
					int nrpos;
					if(i < 2) nrpos = 25;
					else nrpos = (a ? 25LL : 24LL);
					add(dp[(i + 1) & 1][j][b][0], 1LL * nrpos * dp[i & 1][j][a][b]);
				}
	}
	
	dp2[0][0][0][0][0] = 1;
	for(int i = 0; i < n; ++i) {
		memset(dp2[(i + 1) & 1], 0, sizeof dp2[(i + 1) & 1]);

		for(int j = 0; j <= i; ++j)
			for(int k = 0; j + k <= i; ++k)
				for(int a = 0; a < 3; ++a)
					for(int b = 0; b < 3; ++b) {
						// chose a
						if(a != 1) add(dp2[(i + 1) & 1][j + 1][k][b][1], dp2[i & 1][j][k][a][b]);
						
						// chose b
						if(a != 2) add(dp2[(i + 1) & 1][j][k + 1][b][2], dp2[i & 1][j][k][a][b]);

						// chose !a && !b
						int nrpos;
						if(i < 2) nrpos = 24;
						else nrpos = (a ? 24LL : 23LL);
						add(dp2[(i + 1) & 1][j][k][b][0], 1LL * nrpos * dp2[i & 1][j][k][a][b]);
					}
	}
}

ll get(int m[2][2]) {
	return (ll) m[0][0] + m[0][1] + m[1][0] + m[1][1];
}

ll get(int m[3][3]) {
	ll ans = 0;
	for(int i = 0; i < 3; ++i)
		for(int j = 0; j < 3; ++j) ans += m[i][j];
	return ans;
}

int main()
{
	ios_base::sync_with_stdio(false);
	
	int n;

	cin >> n;
	for(int i = 0; i < A; ++i) cin >> cnt[i];

	precalc(n);

	int ans = 26 * 26;
	for(int i = 3; i <= n; ++i) ans = (ans * 25LL) % MOD;

	for(int i = 0; i < A; ++i)
		for(int j = i + 1; j < A; ++j)
			for(int x = cnt[i] + 1; x <= n; ++x)
				for(int y = cnt[j] + 1; x + y <= n; ++y)
					sub(ans, get(dp2[n & 1][x][y]));

	for(int i = 0; i < A; ++i) {
		int tmp = 0;
		for(int x = cnt[i] + 1; x <= n; ++x) {
			add(tmp, get(dp[n & 1][x]));
			for(int j = 0; j < A; ++j) {
				if(i == j) continue;
				for(int y = cnt[j] + 1; x + y <= n; ++y)
					sub(tmp, get(dp2[n & 1][x][y]));
			}
		}

		sub(ans, tmp);
	}

	cout << ans << '\n';
	return 0;
}