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 NN 410

using namespace std;
using INT=long long;
const int mod = 998244353;

int power(int a, int b, int m, int ans = 1) {
	for(; b; b >>= 1, a = 1LL * a * a % m) if(b & 1) ans = 1LL * ans * a % m;
	return ans;
}

int dp[NN][NN][3][3], tmp[NN][NN][3][3];
int ans[NN][NN];

void add(int &x, int y) {
	x += y;
	if(x >= mod) x -= mod;
}

void solve(int n) {
	dp[0][0][2][2] = 24 * 24;
	dp[1][0][0][2] = dp[1][0][2][0] = 24;
	dp[0][1][1][2] = dp[0][1][2][1] = 24;
	dp[1][1][0][1] = dp[1][1][1][0] = 1;
	dp[2][0][0][0] = dp[0][2][1][1] = 1;
	
	for(int i = 2; i < n; i ++) {
		for(int j = 0; j <= i; j ++) {
			for(int k = 0; k + j <= i; k ++) {
				for(int l = 0; l < 3; l ++) {
					for(int m = 0; m < 3; m ++) {
						if(l < 2) {
							add(tmp[j][k][m][2], (INT) dp[j][k][l][m] * 24 % mod);
							int a = j, b = k;
							if(l == 0) b ++;
							else a ++;
							add(tmp[a][b][m][l^1], dp[j][k][l][m]);
						} else {
							add(tmp[j+1][k][m][0], dp[j][k][l][m]);
							add(tmp[j][k+1][m][1], dp[j][k][l][m]);
							add(tmp[j][k][m][2], (INT) dp[j][k][l][m] * 23 % mod);
						}
					}
				}
			}
		}
		for(int j = 0; j <= i + 1; j ++) for(int k = 0; k + j <= i + 1; k ++) 
			for(int l = 0; l < 3; l ++) for(int m = 0; m < 3; m ++) {
				dp[j][k][l][m] = tmp[j][k][l][m];
				tmp[j][k][l][m] = 0;
			}
	}
	for(int i = 0; i <= n; i ++) {
		for(int j = 0; j <= n; j ++) {
			for(int k = 0; k < 3; k ++) {
				for(int l = 0; l < 3; l ++) {
					add(ans[i][j], dp[i][j][k][l]);
				}
			}
		}
	}
}

int cnt[30];

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
#endif
	int n;
	cin >> n;
	solve(n);
	
	int sum = 0;
	
	for(int i = 1; i <= 26; i ++) scanf("%d", &cnt[i]);
	int tot = (INT) 26 * 26 * power(25, n - 2, mod) % mod;
	
	for(int i = 1; i <= 26; i ++) {
		for(int j = cnt[i] + 1; j <= n; j ++) {
			int sum = 0;
			for(int k = 0; k <= n - j; k ++) sum = (sum + ans[j][k]) % mod;
			tot = (tot - sum) % mod;
		}
	}
	
	tot = (tot + mod) % mod;
	
	for(int i = 1; i <= 26; i ++) {
		for(int j = i + 1; j <= 26; j ++) {
			for(int x = cnt[i] + 1; x <= n; x ++) {
				for(int y = cnt[j] + 1; y <= n; y ++) {
					tot = (tot + ans[x][y]) % mod;
				}
			}
		}
	}
	
	tot = (tot + mod) % mod;
	cout << tot << endl;
	return 0;
}