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;

#define fr(i, n) for(ll i = 0; i < n; i++)
#define frr(i, n) for(ll i = 1; i <= n; i++)
#define frm(i, n) for(ll i = n-1; i >= 0; i--)

#define pb push_back
#define f first
#define s second

typedef long long ll;
typedef pair<ll,ll> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> ponto;
typedef vector<vector<ll>> matrix;

#define mem(v, k) memset(v, k, sizeof(v));

#define db cout << "Debug" << endl;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

#define mp make_pair
#define pq priority_queue

#define mx(a, b) a = max(a, b);
#define mod(a, b) a = a%b;

#define MAXN 410
#define MOD 998244353
#define MAXL 30
#define ROOT 1
#define INF 1000000000000000100
inline void sum(ll & a, ll b){a = (a + b + MOD)%MOD;}

ll n;
ll fr[30];

/*
	dp[pos][usado0][usado1][prv][last];
	0 -> tipo0
	1 -> tipo1
	2 -> Não é tipo0 nem tipo1
*/

ll dp[2][MAXN][MAXN][3][3];

void buildDP(){
	dp[0][0][0][2][2] = 24*24;
	dp[0][2][0][0][0] = 1;
	dp[0][0][2][1][1] = 1;

	dp[0][1][0][0][2] = 24;
	dp[0][1][0][2][0] = 24;
	dp[0][0][1][2][1] = 24;
	dp[0][0][1][1][2] = 24;
	dp[0][1][1][1][0] = 1;
	dp[0][1][1][0][1] = 1;

	for(ll pos = 1; pos < n-1; pos++){
		for(ll u1 = 0; u1 <= n; u1++){
			for(ll u2 = 0; u2 <= n; u2++){
				sum(dp[1][u1][u2+1][0][1], dp[0][u1][u2][0][0]);
				sum(dp[1][u1][u2][0][2], 24*dp[0][u1][u2][0][0]);
				
				sum(dp[1][u1][u2+1][1][1], dp[0][u1][u2][0][1]);
				sum(dp[1][u1][u2][1][2], 24*dp[0][u1][u2][0][1]);

				sum(dp[1][u1][u2+1][2][1], dp[0][u1][u2][0][2]);
				sum(dp[1][u1][u2][2][2], 24*dp[0][u1][u2][0][2]);
				
				sum(dp[1][u1+1][u2][1][0], dp[0][u1][u2][1][1]);
				sum(dp[1][u1][u2][1][2], 24*dp[0][u1][u2][1][1]);
				
				sum(dp[1][u1+1][u2][0][0], dp[0][u1][u2][1][0]);
				sum(dp[1][u1][u2][0][2], 24*dp[0][u1][u2][1][0]);

				sum(dp[1][u1+1][u2][2][0], dp[0][u1][u2][1][2]);
				sum(dp[1][u1][u2][2][2], 24*dp[0][u1][u2][1][2]);
				
				sum(dp[1][u1+1][u2][0][0], dp[0][u1][u2][2][0]);
				sum(dp[1][u1][u2+1][0][1], dp[0][u1][u2][2][0]);
				sum(dp[1][u1][u2][0][2], 23*dp[0][u1][u2][2][0]);		

				sum(dp[1][u1][u2+1][1][1], dp[0][u1][u2][2][1]);
				sum(dp[1][u1+1][u2][1][0], dp[0][u1][u2][2][1]);
				sum(dp[1][u1][u2][1][2], 23*dp[0][u1][u2][2][1]);	

				sum(dp[1][u1+1][u2][2][0], dp[0][u1][u2][2][2]);	
				sum(dp[1][u1][u2+1][2][1], dp[0][u1][u2][2][2]);	
				sum(dp[1][u1][u2][2][2], 23*dp[0][u1][u2][2][2]);

			}
		}

		swap(dp[0], dp[1]);
		for(ll u1 = 0; u1 <= n; u1++){
			for(ll u2 = 0; u2 <= n; u2++){
				fr(pen, 3) fr(ult, 3){
					dp[1][u1][u2][pen][ult] = 0;
				}
			}
		}
	}
}

ll getTotal(){
	ll ans = 0;
	for(ll u1 = 0; u1 <= n; u1++){
		for(ll u2 = 0; u2 <= n; u2++){
			fr(pen, 3) fr(ult, 3)
				sum(ans, dp[0][u1][u2][pen][ult]);
		}
	}

	return ans;
}

ll getOne(ll ind){
	ll ans = 0;
	for(ll u1 = fr[ind] + 1; u1 <= n; u1++){
		for(ll u2 = 0; u2 <= n; u2++){
			fr(pen, 3) fr(ult, 3){
				sum(ans, dp[0][u1][u2][pen][ult]);
				/*
				cout << u1 << " " << u2 << endl;
				cout << dp[0][u1][u2][pen][ult] << endl;
				cout << dp[1][u1][u2][pen][ult] << endl;
				db;
				*/
			}
		}
	}
	return ans;
}

ll acu[MAXN][MAXN];
ll getAllTwo(){
	for(ll u1 = n; u1 >= 0; u1--){
		for(ll u2 = n; u2 >= 0; u2--){
			fr(pen, 3) fr(ult, 3)
				sum(acu[u1][u2], dp[0][u1][u2][pen][ult]);

			sum(acu[u1][u2], acu[u1 + 1][u2]);
			sum(acu[u1][u2], acu[u1][u2 + 1]);
			sum(acu[u1][u2], -acu[u1 + 1][u2 + 1]);	
		}
	}
	
	

	ll ans = 0;
	fr(i, 26){
		fr(j, i){
			sum(ans, acu[fr[i] + 1][fr[j] + 1]);
		}
	}

	return ans;
}

int main(){
	fastio;
	cin >> n;
	fr(i, 26) cin >> fr[i];

	buildDP();

	ll ans = getTotal();
	fr(i, 26) {
		sum(ans, -getOne(i));
	}

	sum(ans, getAllTwo());
	cout << ans << endl;
}