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 <iostream>
using namespace std;

#define int long long

const int MAX_N = 400 + 7;
const int MOD = 998244353;

int bin(int x, int n) {
    int ret = 1;
    for (; n; n >>= 1, x = x * x % MOD)
        if (n & 1) ret = ret * x % MOD;
    return ret;
}

int n, ans;
int c[26];

int dp1[MAX_N][2][2];
int dp2[MAX_N][MAX_N][3][3];
int tmp[MAX_N][MAX_N][3][3];

signed main() {
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < 26; ++i) {
        cin >> c[i];
    }

    dp1[0][0][0] = 25 * 25;
    dp1[1][0][1] = dp1[1][1][0] = 25;
    dp1[2][1][1] = 1;
    for (int i = 3; i <= n; ++i) {
        for (int j = i; j >= 1; --j) {
            dp1[j][0][0] = (25 * dp1[j][1][0] + 24 * dp1[j][0][0]) % MOD;
            dp1[j][1][0] = (25 * dp1[j][1][1] + 24 * dp1[j][0][1]) % MOD;
            dp1[j][1][1] = dp1[j - 1][0][1];
            dp1[j][0][1] = dp1[j - 1][0][0];
        }
        dp1[0][0][0] = 24 * dp1[0][0][0] % MOD;
    }

    dp2[0][0][0][0] = 24 * 24;
    dp2[1][0][1][0] = dp2[1][0][0][1] = dp2[0][1][2][0] = dp2[0][1][0][2] = 24;
    dp2[2][0][1][1] = dp2[1][1][1][2] = dp2[1][1][2][1] = dp2[0][2][2][2] = 1;
    for (int i = 3; i <= n; ++i) {
        for (int j = i; j >= 0; --j) {
            for (int k = i; k >= 0; --k) {
                tmp[j][k][0][0] = (23 * dp2[j][k][0][0] + 24 * dp2[j][k][1][0] +
                                   24 * dp2[j][k][2][0]) %
                                  MOD;
                tmp[j][k][1][0] = (23 * dp2[j][k][0][1] + 24 * dp2[j][k][1][1] +
                                   24 * dp2[j][k][2][1]) %
                                  MOD;
                tmp[j][k][2][0] = (23 * dp2[j][k][0][2] + 24 * dp2[j][k][1][2] +
                                   24 * dp2[j][k][2][2]) %
                                  MOD;

                tmp[j][k][0][1] =
                    (dp2[j - 1][k][0][0] + dp2[j - 1][k][2][0]) % MOD;
                tmp[j][k][0][2] =
                    (dp2[j][k - 1][0][0] + dp2[j][k - 1][1][0]) % MOD;
                tmp[j][k][1][1] =
                    (dp2[j - 1][k][0][1] + dp2[j - 1][k][2][1]) % MOD;
                tmp[j][k][1][2] =
                    (dp2[j][k - 1][0][1] + dp2[j][k - 1][1][1]) % MOD;
                tmp[j][k][2][1] =
                    (dp2[j - 1][k][0][2] + dp2[j - 1][k][2][2]) % MOD;
                tmp[j][k][2][2] =
                    (dp2[j][k - 1][0][2] + dp2[j][k - 1][1][2]) % MOD;
            }
        }
        tmp[0][0][0][0] = 23 * dp2[0][0][0][0] % MOD;
        for (int j = 0; j <= i; ++j)
            for (int k = 0; k <= i; ++k)
                for (int xx = 0; xx < 3; ++xx)
                    for (int yy = 0; yy < 3; ++yy)
                        dp2[j][k][xx][yy] = tmp[j][k][xx][yy];
    }

    ans = 26 * 26 * bin(25, n - 2) % MOD;
    for (int i = 0; i < 26; ++i) {
        for (int k = c[i] + 1; k <= n; ++k)
            ans = (ans - dp1[k][0][0] - dp1[k][0][1] - dp1[k][1][0] -
                   dp1[k][1][1] + MOD) %
                  MOD;
    }

    for (int i = 0; i < 26; ++i) {
        for (int j = i + 1; j < 26; ++j) {
            for (int p = c[i] + 1; p <= n; ++p)
                for (int q = c[j] + 1; q <= n; ++q) {
                    for (int xx = 0; xx < 3; ++xx)
                        for (int yy = 0; yy < 3; ++yy) {
                            ans += dp2[p][q][xx][yy];
                        }
                    ans %= MOD;
                }
        }
    }

    cout << ans << endl;

    return 0;
}