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>

using namespace std;

#define f first
#define s second

typedef long long ll;
typedef pair<int,int> pi;

const ll mod = 998244353;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    vector<int> nums(26);
    for(int i = 0; i < 26; i++) cin >> nums[i];
    int p = (n+1)/2 + 11;
    ll dp[2][p+1][p+1][3][3];
    for(int i = 0; i <= p; i++){
        for(int j = 0; j <= p; j++){
            for(int sl = 0; sl < 3; sl++){
                for(int l = 0; l < 3; l++){
                    dp[0][i][j][sl][l] = 0;
                }
            }
        }
    }
    for(int i = 0; i < 3; i++){
        int mul1 = 1;
        if(i == 0) mul1 = 24;
        for(int j = 0; j < 3; j++){
            int mul2 = 1;
            if(j == 0) mul2 = 24;
            dp[0][!!(i == 1)+!!(j == 1)][!!(i == 2)+!!(j == 2)][i][j] = mul1*mul2;
        }
    }
    for(int t = 3; t <= n; t++){
        for(int i = p; i >= 0; i--){
            for(int j = p; j >= 0; j--){
                for(int sl = 0; sl < 3; sl++){
                    for(int l = 0; l < 3; l++){
                        dp[t&1][i][j][sl][l] = 0;
                        if((l == 1 || sl == 1) && i == 0) continue;
                        if((l == 2 || sl == 2) && j == 0) continue;
                        for(int tl = 0; tl < 3; tl++){
                            ll mult = 1;
                            if(l == tl){
                                if(l != 0) continue;
                                else mult = 23;
                            }else if(l == 0) mult = 24;

                            dp[t&1][i][j][sl][l] += mult*dp[(t-1)&1][i-!!(l == 1)][j - !!(l == 2)][tl][sl];
                            dp[t&1][i][j][sl][l] %= mod;
                        }
                    }
                }
            }
        }
    }
    ll suf[p+1][p+1];
    for(int i = p; i >= 0; i--){
        for(int j = p; j >= 0; j--){
            suf[i][j] = 0;
            for(int sl = 0; sl < 3; sl++){
                for(int l = 0; l < 3; l++){
                    suf[i][j] += dp[n&1][i][j][sl][l];
                    if(suf[i][j] >= mod) suf[i][j] -= mod;
                }
            }
        }
    }
    for(int i = p-1; i >= 0; i--){
        for(int j = p-1; j >= 0; j--){
            suf[i][j] += suf[i+1][j];
            suf[i][j] += suf[i][j+1];
            suf[i][j] -= suf[i+1][j+1];
            if(suf[i][j] < 0) suf[i][j] += mod;
            suf[i][j] %= mod;
        }
    }
    ll ans = suf[0][0];
    for(int i = 0; i < 26; i++){
        if(nums[i] >= p-1) continue;
        ans -= suf[nums[i]+1][0];
        if(ans < 0) ans += mod;
    }
    for(int i = 0; i < 26; i++){
        if(nums[i] >= p-1) continue;
        for(int j = i+1; j < 26; j++){
            if(nums[j] >= p-1) continue;
            ans += suf[nums[i]+1][nums[j]+1];
            if(ans >= mod) ans -= mod;
        }
    }
    cout << ans << "\n";
    return 0;
}