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 all(x) (x).begin() , (x).end()
#define rall(x) (x).rbegin() , (x).rend()
#define pb push_back
//#define Nength(x) (int)(x).size()
using namespace std;
typedef long long ll;
typedef long double ld;
//const int L = 401;
const int N = 401;


const int mod = 998244353;

int c[26];
int f[2][N][N][3][3];
long long pref[N][N];
void md(int &a){
    if(a >= mod)
        a-=mod;
}
void md(long long &a){
    if(a >= mod)
        a-=mod;
}
void build_sums(int n){
    /// okay let go
    for(int i = 0 ; i < N; ++i){
        for(int j =0 ;  j < N; ++j){
            if(j - 1 >= 0)
                pref[i][j] += pref[i][j-1], md(pref[i][j]);
            if(i - 1 >= 0)
                pref[i][j] += pref[i-1][j] , md(pref[i][j]);
            if(i - 1 >= 0 && j- 1 >= 0)
                pref[i][j] = (mod + pref[i][j] - pref[i-1][j-1]) , md(pref[i][j]);
            /// now current
            for(int x=0;x<3;++x)
            for(int xx=0;xx<3;++xx){
                pref[i][j] += f[n][i][j][x][xx];
                md(pref[i][j]);
            }
        }
    }
}

int get(int x , int x1 , int y , int y1){
    if(x > x1)
        return 0;
    if(y > y1)
        return 0;
    long long ans = 0ll + (pref[x1][y1] - (x-1>=0?pref[x-1][y1]:0)) - (y-1>=0?pref[x1][y-1]:0) + ((x-1>=0&&y-1>=0)?pref[x-1][y-1]:0);
    ans += 5ll*mod;
    ans %= mod;
    return ans;
}
signed main(){
    int n;
    cin >> n;
    for(int i = 0 ; i < 26; ++i){
        cin >> c[i];
    }
    /// think about very first states

    /// first states okay


    int bt = 0;
    for(auto ch : {0 , 1 , 2})
        for(auto ch1 : {0 , 1,  2}){
            int c1 = 0 , c2 = 0;
            if(ch == 0)c1++;
            if(ch == 1)c2++;
            if(ch1 == 0)c1++;
            if(ch1 == 1)c2++;
             f[bt][c1][c2][ch][ch1] += (ch==2?26-2:1) * (ch1==2?26-2:1);
            md(f[bt][c1][c2][ch][ch1]);
        }

    for(int i = 3; i <= n; ++i){
        /// okay what if?
        bt ^= 1;
        for(int x=0;x<=i;++x)
            for(int xx=0;xx<=i;++xx)
                for(int F=0;F<3;++F)
                    for(int ff=0;ff<3;++ff)
                        f[bt][x][xx][F][ff] = 0;
        for(auto c1=0;c1<=i;++c1){
            for(auto c2=0;c2<=i-c1;++c2){
                for(auto was : {0 , 1 , 2}){
                    for(auto prv : {0 , 1 , 2}){
                        for(auto ch : {0 , 1 , 2}){
                            if(ch == was && ch != 2)
                                continue;
                            int nwc1 = c1 , nwc2 = c2;
                            int var = 0;
                            if(was != 2){
                                if(ch == 2)
                                    var = 26 - 2;
                                else
                                    var = 1;
                            }else{
                                if(ch == 2)
                                var = 26 - 3;
                                else
                                    var = 1;
                            }

                            if(ch == 0)
                                nwc1++;
                            if(ch == 1)
                                nwc2++;
                            f[bt][nwc1][nwc2][prv][ch] += (1ll * f[bt^1][c1][c2][was][prv] * var) %mod;
                            md(f[bt][nwc1][nwc2][prv][ch]);
                        }
                    }
                }
            }
        }
    }
    /// so here we want to make pref sums



    build_sums(bt);
    /// just do it okay
    /// firstly we need to add with >= 0
    ll answer = 0;
    answer +=  get(0, n , 0 , n) % mod;
    answer %= mod;
//    answer += 1ll * (26 ) * (25) / 2 * f[n][1..n][1..n][0..2][0..2];
    /// next - with >=1
    for(int i = 0 ; i < 26; ++i){
          answer -= 1ll * get(c[i]+1,n , 0,n);
          answer += mod;
          answer %= mod;
//        answer -= 1ll * (25-i) * f[n][c[i]+1..n][1..n][0..2][0..2];
    }
    /// and next add with >= 2
    for(int i = 0 ; i < 26; ++i){
        for(int j = i + 1; j < 26; ++j){
//            answer += 1ll * f[n][c[i]+1..n][c[j]+1..n][0..2][0..2];
            answer += get(c[i]+1,n, c[j]+1,n);
            answer %= mod;
        }
    }

    cout << answer % mod;
    return 0;
}