#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <set>
using namespace std;
#define ll long long
#define ull unsigned long long
#define fi first
#define se second
#define dingyi int mid = l + r >> 1, ls = p << 1, rs = p << 1 | 1
#define y0 y_csyakioi_0
#define y1 y_csyakioi_1
#define rep(i, x, y) for(int i = x; i <= y; ++i)
#define per(i, x, y) for(int i = x; i >= y; --i)
#define repg(i, u) for(int i = head[u]; i; i = e[i].nxt)
inline int read(){
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9'){ if(ch == '-') f = -1; ch = getchar(); }
	while(ch >= '0' && ch <= '9'){ x = x * 10 + (ch ^ 48); ch = getchar(); }
	return x * f;
}
const int N = 410, mod = 998244353;
int n, c[N], sum[N][N], f[2][N][N][3][3]; 
inline void mian(){
	n = read(); rep(i, 1, 26) c[i] = read(); f[1][0][0][0][2] = 24; f[1][0][1][0][1] = f[1][1][0][0][0] = 1;
	rep(i, 0, n) rep(j, 0, n){
		if(i) rep(k, 0, 2) f[0][i][j][k][0] = (f[0][i][j][k][0] + f[1][i - 1][j][0][k]) % mod;
		if(j) rep(k, 0, 2) f[0][i][j][k][1] = (f[0][i][j][k][1] + f[1][i][j - 1][0][k]) % mod;
		rep(k, 0, 2) f[0][i][j][k][2] = (f[0][i][j][k][2] + 24ll * f[1][i][j][0][k] % mod) % mod;
	}
	rep(i, 3, n){
		int t = i & 1, t_ = i & 1 ^ 1; memset(f[t], 0, sizeof(f[t]));
		rep(j, 0, n) rep(k, 0, n){
			if(j) rep(p, 0, 2) rep(l, 1, 2) f[t][j][k][p][0] = (f[t][j][k][p][0] + f[t_][j - 1][k][l][p]) % mod;
			if(k) rep(p, 0, 2) rep(l, 0, 2) if(l != 1) f[t][j][k][p][1] = (f[t][j][k][p][1] + f[t_][j][k - 1][l][p]) % mod;
			rep(p, 0, 2) rep(l, 0, 2) f[t][j][k][p][2] = (f[t][j][k][p][2] + 1ll * f[t_][j][k][l][p] * (24 - (l == 2)) % mod) % mod; 
		}
	} 
	rep(i, 0, n) rep(j, 0, n) rep(k, 0, 2) rep(p, 0, 2) sum[i][j] = (sum[i][j] + f[n & 1][i][j][k][p]) % mod;
	per(i, n, 0) per(j, n, 0) sum[i][j] = (((sum[i][j] + sum[i][j + 1]) % mod + sum[i + 1][j]) % mod - sum[i + 1][j + 1] + mod) % mod;
	int ans = sum[0][0]; rep(i, 1, 26) ans = (ans - sum[c[i] + 1][0] + mod) % mod;
	rep(i, 1, 25) rep(j, i + 1, 26) ans = (ans + sum[c[i] + 1][c[j] + 1]) % mod; printf("%d\n", ans);
}
int main(){ int qwq = 1; while(qwq--) mian(); return 0; }
/*
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
*/