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 fi first
#define se second
#define gc getchar() //(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define IT iterator
#define V vector
#define TP template <class o>
#define TPP template <typename t1, typename t2>
#define SZ(a) ((int)a.size())
#define all(a) a.begin(), a.end()
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define REP(i, a, b) for (int i = b; i >= a; i--)
#define FOR(i,n) rep(i,1,n)
#define debug(x) cerr << #x << " = " << x << endl
using namespace std;
typedef unsigned ui;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
const int N = 410, size = 1 << 20, mod = 998244353, inf = 2e9;
const ll INF = 1e15;

// char buf[size],*p1=buf,*p2=buf;
TP void qr(o& x) {
    char c = gc;
    x = 0;
    int f = 1;
    while (!isdigit(c)) {
        if (c == '-')
            f = -1;
        c = gc;
    }
    while (isdigit(c))
        x = x * 10 + c - '0', c = gc;
    x *= f;
}
template<class o,class ... O> void qr(o& x, O& ... y) {qr(x); qr(y...);}
TP void qw(o x) {
    if (x / 10)
        qw(x / 10);
    putchar(x % 10 + '0');
}
TP void pr1(o x) {
    if (x < 0)
        x = -x, putchar('-');
    qw(x);
    putchar(' ');
}
template<class o,class ... O> void pr1(o x, O ... y) { pr1(x); pr1(y...);}
TP void pr2(o x) {
    if (x < 0)
        x = -x, putchar('-');
    qw(x);
    putchar('\n');
}
template<class o,class ... O> void pr2(o x, O ... y) { pr2(x); pr2(y...);}

// math
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll power(ll a, ll b = mod - 2, ll p = mod) {
    ll c = 1;
    while (b) {
        if (b & 1) c = c * a % p;
        b /= 2;
        a = a * a % p;
    }
    return c;
}
ll exgcd(ll a,ll b,ll &x,ll &y) {
	if(!a) {x=0; y=1; return b;}
	ll d=exgcd(b%a,a,y,x); x -= b/a*y;
	return d;
}
ll INV(ll n,ll p=mod) {ll x,y; exgcd(n,p,x,y); return (x%p+p)%p;}

TP void cmax(o& x, o y) {
    if (x < y)
        x = y;
}
TP void cmin(o& x, o y) {
    if (x > y)
        x = y;
}
TPP void ad(t1& x, t2 y) {
    x += y;
    if (x >= mod)
        x -= mod;
}
TPP void dl(t1& x, t2 y) {
    x -= y;
    if (x < 0)
        x += mod;
}

int n, a[33], ans, suf[N][N], h[2][N][N][9];

void solve() {
	qr(n); FOR(i, 26) qr(a[i]);
	ll ans = 0;
	rep(i, 0, 2) rep(j, 0, 2) 
		h[0][(i == 1) + (j == 1)][(i == 2) + (j == 2)][i + j * 3] = (i ? 1 : 24) * (j ? 1 : 24);
	int now = 0;
	rep(T, 3, n) {
		now ^= 1;
		memset(h[now], 0, sizeof h[now]);
		rep(i, 0, T) rep(j, 0, T - i) rep(k, 0, 8) if(h[!now][i][j][k]) 
			rep(l, 0, 2) {
				if(l && k % 3 == l) continue;
				ad(h[now][i + (l == 1)][j + (l == 2)][k / 3 + l * 3], h[!now][i][j][k] * (l ? 1ll : 24ll - (k % 3 == 0)) % mod);
			}
	}
	REP(i, 0, n) REP(j, 0, n) {
		dl(suf[i][j] = (suf[i + 1][j] + suf[i][j + 1]) % mod,  suf[i + 1][j + 1]);
		rep(k, 0, 8) ad(suf[i][j], h[now][i][j][k]);
	}
	ans = suf[0][0];
	FOR(i, 26) 
		ans -= suf[++a[i]][0];
	FOR(i, 26) 
		rep(j, i + 1, 26) 
			ans += suf[a[i]][a[j]];
	dl(ans %= mod, 0); pr2(ans);
}

int main() {
    int T = 1;
//    qr(T);
    while (T--)
        solve();
    return 0;
}