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>

//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

using namespace std;

#define f first
#define s second
#define int long long
#define pb push_back
#define ld long double

const int N = 400 + 10, mod = 998244353, inf = 1e15 + 10;

int c[N], dp[N][N][2][2], dp1[2][N][N][3][3];

int bp(int a, int n){
    if(n == 0)
        return 1;
    int t = bp(a, n / 2);
    if(n % 2)
        return t * t % mod * a % mod;
    else
        return t * t % mod;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n; cin >> n;
    for(int i = 0; i < 26; ++i)
        cin >> c[i];
    int ans = 26 * 26 * bp(25, n - 2) % mod;
    dp[0][0][0][0] = 1;
    for(int i = 0; i <= n; ++i)
        for(int j = 0; j <= i; ++j)
            for(int k = 0; k <= 1; ++k)
                for(int k1 = 0; k1 <= 1; ++k1)
                    for(int k2 = 0; k2 <= 1; ++k2){
                        if(k!=k2 && k2 == 1)
                            dp[i + 1][j + k2][k1][k2] = (dp[i + 1][j + k2][k1][k2] + dp[i][j][k][k1]) % mod;
                        if(k2 == 0)
                            if(i >= 2)
                                dp[i + 1][j + k2][k1][k2] = (dp[i + 1][j + k2][k1][k2] + dp[i][j][k][k1] * (24 + (bool)(k != 0))) % mod;
                            else
                                dp[i + 1][j + k2][k1][k2] = (dp[i + 1][j + k2][k1][k2] + dp[i][j][k][k1] * (25)) % mod;
                    }
    dp1[0][0][0][0][0] = 1;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j <= i; ++j)
            for(int q = 0; q <= i - j; ++q)
                for(int k = 0; k <= 2; ++k)
                    for(int k1 = 0; k1 <= 2; ++k1)
                        for(int k2 = 0; k2 <= 2; ++k2){
                            if(k2 != k && k2)
                                dp1[1][j + (k2 == 1)][q + (k2 == 2)][k1][k2] = (dp1[1][j + (k2 == 1)][q + (k2 == 2)][k1][k2] + dp1[0][j][q][k][k1]) % mod;
                            else if(k2 == 0)
                                if(i >= 2)
                                    dp1[1][j][q][k1][k2] = (dp1[1][j][q][k1][k2] + dp1[0][j][q][k][k1] * (23 + (bool)(k != 0))) % mod;
                                else
                                    dp1[1][j][q][k1][k2] = (dp1[1][j][q][k1][k2] + dp1[0][j][q][k][k1] * (24)) % mod;
                        }
//    cout << 1 << endl;
        swap(dp1[0], dp1[1]);
        for(int j = 0; j <= n; ++j)
            for(int q = 0; q <= n; ++q)
                for(int k = 0; k <= 2; ++k)
                    for(int k1 = 0; k1 <= 2; ++k1)
                        dp1[1][j][q][k][k1] = 0;
    }
    for(int i = 0; i < 26; ++i)
        for(int j = c[i] + 1; j <= n; ++j)
            for(int k = 0; k <= 1; ++k)
                for(int k1 = 0; k1 <= 1; ++k1)
                    ans = (ans + mod - dp[n][j][k][k1]) % mod;
    for(int i = 0; i < 26; ++i)
        for(int j = i+1; j < 26; ++j)
            for(int q = c[i] + 1; q <= n; ++q)
                for(int q1 = c[j] + 1; q1 <= n - q; ++q1)
                    for(int k = 0; k <= 2; ++k)
                        for(int k1 = 0; k1 <= 2; ++k1)
                            ans = (ans + dp1[0][q][q1][k][k1]) % mod;
    cout << ans;
}