#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;
}
