#include<bits/stdc++.h>
#define LL long long 
#define fi first
#define se second
#define mp make_pair
#define PLL pair<LL, LL>
#define PIL pair<int, LL>
#define PII pair<int, int>

using namespace std;

const int N = 407;
const int mod = 998244353;

int n, c[27];
int dp[2][N][N][3][3];
int f[N][N][2][2];

inline void add(int& a, int b) {
	a += b;
	if (a >= mod) a -= mod;
}

inline void sub(int& a, int b) {
	a -= b;
	if (a < 0) a += mod;
}

void clear_dp(int cur, int n) {
	for (int n1 = 0; n1 <= n; n1++) {
		for (int n2 = 0; n1 + n2 <= n; n2++) {
			for (int c1 = 0; c1 < 3; c1++) {
				for (int c2 = 0; c2 < 3; c2++) {
					dp[cur][n1][n2][c1][c2] = 0;
				}
			}
		}
	}
}

void solve() {
	scanf("%d", &n);
	for (int i = 1; i <= 26; i++) scanf("%d", &c[i]);
	int cur = 0, pre = 1;
	dp[cur][0][0][0][0] = 1;
	for (int i = 0; i < n; i++) {
		swap(cur, pre);
		clear_dp(cur, i + 1);
		for (int n1 = 0; n1 <= i; n1++) {
			for (int n2 = 0; n1 + n2 <= i; n2++) {
				for (int c1 = 0; c1 < 3; c1++) {
					for (int c2 = 0; c2 < 3; c2++) {
						if (!dp[pre][n1][n2][c1][c2]) continue;
						int v = dp[pre][n1][n2][c1][c2];
						int base = 24 - (i > 1 && !c1);
						for (int c3 = 0; c3 < 3; c3++) {
							if (c3 && c3 == c1) continue;
							if (c3 == 1) add(dp[cur][n1 + 1][n2][c2][c3], v);
							else if (c3 == 2) add(dp[cur][n1][n2 + 1][c2][c3], v);
							else if (c3 == 0) add(dp[cur][n1][n2][c2][c3], 1LL * base * v % mod);
						}
					}
				}
			}
		}
	}
	f[0][0][0][0] = 1;
	for (int i = 0; i < n; i++) {
		for (int n1 = 0; n1 <= i; n1++) {
			for (int c1 = 0; c1 < 2; c1++) {
				for (int c2 = 0; c2 < 2; c2++) {
					if (!f[i][n1][c1][c2]) continue;
					int v = f[i][n1][c1][c2];
					int base = 25 - (i > 1 && !c1);
					for (int c3 = 0; c3 < 2; c3++) {
						if (c3 && c3 == c1) continue;
						if (c3 == 1) add(f[i + 1][n1 + 1][c2][c3], v);
						else add(f[i + 1][n1][c2][c3], 1LL * base * v % mod);
					}
				}
			}
		}
	}
	int ans = 26 * 26;
	for (int i = 3; i <= n; i++) ans = 1LL * ans * 25 % mod;
	// sub one over
	for (int i = 1; i <= 26; i++) {
		int value = 0;
		for (int a = c[i] + 1; a <= n; a++) {
			for (int b = 0; b < 2; b++) {
				for (int c = 0; c < 2; c++) {
					// printf("i: %d  a: %d  b: %d  c: %d   %d\n", i, a, b, c, f[n][a][b][c]);
					add(value, f[n][a][b][c]);
				}
			}
		}
		sub(ans, value);
	}
	// add two over
	for (int i = 1; i <= 26; i++) {
		for(int j = i + 1; j <= 26; j++) {
			int value = 0;
			int up1 = c[i], up2 = c[j];
			for (int a = up1 + 1; a <= n; a++) {
				for (int b = up2 + 1; a + b <= n && b <= n; b++) {
					int mn = min(a, b);
					int mx = max(a, b);
					for (int c = 0; c < 3; c++) {
						for (int d = 0; d < 3; d++) {
							add(value, dp[cur][a][b][c][d]);
						}
					}
				}
			}
			add(ans, value);
		}
	}
	printf("%d\n", ans);
}

int main() {
	int NT = 1;
	while(NT--) solve();
	return 0;
}