#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
 
#define F first
#define S second
 
const int MOD = 998244353;//1e9 + 7;//XXX
const int C = 26;//XXX
 
void add(int &x, int y){
	x += y;
	while (x >= MOD) x -= MOD;
	while (x < 0) x += MOD;
}
 
int fix(int x){
	while (x >= MOD) x -= MOD;
	while (x < 0) x += MOD;
	return x;
}
 
int pw(int a, int b){
	int ret = 1;
	while (b){
		if (b & 1)
			ret = 1ll*ret*a%MOD;
		b >>= 1;
		a = 1ll*a*a%MOD;
	}
	return ret;
}

int mul(int a, int b) {
	return (ll) a * b % MOD;
}

#define FOR(i,n) for(int i = 0; i < int(n); i++) 
const int MAXN = 400 + 10;
int n, cnt[C];

int dp1[2][MAXN][2][2]; 
// dp1[prefix][count A][2nd last equal to A][last equal to A] = #ways

int dp2[2][MAXN][MAXN][3][3];
// dp2[prefix][count A][count B][2nd last equal to A or B or neither][last equal to A or B or neither] = #ways

void solve() {
	cin >> n;
	FOR(i, 26) cin >> cnt[i];
	
	int z = 0;
	dp1[z][0][0][0] = 1;
	
	FOR(i,n) {
		memset(dp1[z^1], 0, sizeof(dp1[z^1]));
		FOR(j,n)FOR(k,2) {
			add(dp1[z^1][j][k][0], mul(C - 2 + (i < 2), dp1[z][j][0][k])); // place not A at end with not A at 2nd last
			add(dp1[z^1][j][k][0], mul(C - 1, dp1[z][j][1][k])); // place not A at end with A at 2nd last
			
			add(dp1[z^1][j+1][k][1], dp1[z][j][0][k]); // place A at end
		}
		z ^= 1;
	}
	
	z=0;
	dp2[z][0][0][0][0] = 1;
	FOR(i, n) {
		memset(dp2[z^1], 0, sizeof(dp2[z^1]));
		
		FOR(j, n)FOR(k, n)FOR(last, 3) {
			add(dp2[z^1][j][k][last][0], mul(C - 3 + (i < 2), dp2[z][j][k][0][last])); // place not, A, B, at end with not A, B at 2nd last
			add(dp2[z^1][j][k][last][0], mul(C - 2, dp2[z][j][k][1][last])); // place not A, B at end with A at 2nd last
			add(dp2[z^1][j][k][last][0], mul(C - 2, dp2[z][j][k][2][last])); // place not A, B at end with B at 2nd last
		
			add(dp2[z^1][j+1][k][last][1], dp2[z][j][k][0][last]); // place A
			add(dp2[z^1][j+1][k][last][1], dp2[z][j][k][2][last]);
			
			add(dp2[z^1][j][k+1][last][2], dp2[z][j][k][0][last]); // place B
			add(dp2[z^1][j][k+1][last][2], dp2[z][j][k][1][last]);
		}
		
		z ^= 1;
	}
	
	int ans = mul(26*26, pw(25, n-2)); // all ways, dont care about counts
	for(int i = 0; i < C; i++) {
		for(int j = cnt[i]+1; j <= n; j++) {
			FOR(a,2)FOR(b,2) {
				add(ans, -dp1[z][j][a][b]);
			}
		}
	}
	FOR(i,C)for(int j = i+1; j < C; j++) {
		for(int a = cnt[i]+1; a <= n; a++) {
			for(int b = cnt[j]+1; b <= n; b++) {
				FOR(c,3)FOR(d,3) {
					add(ans, dp2[z][a][b][c][d]);
				}
			}
		}
	}
	cout << ans << "\n";
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//cout << fixed << setprecision(6);
	
	int te = 1;	
	//cin >> te;
	for (int w = 1; w <= te; w++){
		//cout << "Case #" << w << ": ";
		solve();
	}
	return 0;
}
