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;
typedef long long ll;
typedef double db;
typedef pair <int, int> pin;

const int N = 405;
const int M = 105; 
const ll P = 998244353LL;

int n, c[M];
ll f[2][N][N][3][3], sum[N][N][3][3], g[N][N];

template <typename T>
inline void read(T &X) {
    char ch = 0; T op = 1; 
    for (X = 0; ch > '9' || ch < '0'; ch = getchar())
        if (ch == '-') op = -1;
    for (; ch >= '0' && ch <= '9'; ch = getchar())
        X = (X * 10) + ch - '0';
    X *= op;
}

inline void inc(ll &x, ll y) {
    x += y;
    if (x >= P) x -= P;
}

inline void sub(ll &x, ll y) {
    x -= y;
    if (x < 0) x += P;
}

inline void clear(int cur) {
    for (int j = 0; j <= n; j++)
        for (int k = 0; k <= n; k++)
            for (int x = 0; x <= 2; x++)
                for (int y = 0; y <= 2; y++)
                    f[cur][j][k][x][y] = 0;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("sample.in", "r", stdin);
    clock_t st_clock = clock();
#endif

    read(n);
    for (int i = 1; i <= 26; i++) read(c[i]);
    f[0][0][0][0][0] = 24LL * 24LL;
    f[0][1][0][0][1] = 24LL;
    f[0][0][1][0][2] = 24LL;
    f[0][2][0][1][1] = 1LL;
    f[0][1][0][1][0] = 24LL;
    f[0][1][1][1][2] = 1LL;
    f[0][0][2][2][2] = 1LL;
    f[0][1][1][2][1] = 1LL;
    f[0][0][1][2][0] = 24LL;
    // for (int i = 3; i <= n; i++) {
    //     int cur = i & 1, pre = cur ^ 1;
    //     clear(cur);
    //     for (int j = 0; j <= n; j++)
    //         for (int k = 0; k <= n; k++) {
    //             if (j + k > n) break;
    //             for (int x = 0; x <= 2; x++) {
    //                 inc(f[cur][j][k][0][x], f[pre][j][k][x][0] * 23LL % P);
    //                 inc(f[cur][j][k][0][x], f[pre][j][k][x][1] * 24LL % P);
    //                 inc(f[cur][j][k][0][x], f[pre][j][k][x][2] * 24LL % P);
    //                 if (j >= 1) {
    //                     inc(f[cur][j][k][1][x], f[pre][j - 1][k][x][0]);
    //                     inc(f[cur][j][k][1][x], f[pre][j - 1][k][x][2]);
    //                 } 
    //                 if (k >= 1) {
    //                     inc(f[cur][j][k][2][x], f[pre][j][k - 1][x][0]);
    //                     inc(f[cur][j][k][2][x], f[pre][j][k - 1][x][1]);
    //                 }
    //             }
    //         }
    // }

    for (int i = 2; i < n; i++) {
        int cur = i & 1, nxt = cur ^ 1;
        clear(nxt);
        for (int j = 0; j <= n; j++) 
            for (int k = 0; k <= n; k++) {
                for (int x = 0; x <= 2; x++)
                    for (int y = 0; y <= 2; y++) {
                        ll now = f[cur][j][k][x][y];
                        if (now == 0) continue;
                        if (y == 0) inc(f[nxt][j][k][0][x], now * 23LL % P);
                        else inc(f[nxt][j][k][0][x], now * 24LL % P);
                        if (y != 1) inc(f[nxt][j + 1][k][1][x], now);
                        if (y != 2) inc(f[nxt][j][k + 1][2][x], now);
                    }
            }
        // if (i == 2) {
        //     printf("%lld\n", f[1][0][0][0][0]);
        //     printf("%lld\n", f[1][1][0][0][1]);
        //     printf("%lld\n", f[1][0][1][0][2]);
        //     printf("%lld\n", f[1][2][0][1][1]);
        //     printf("%lld\n", f[1][1][0][1][0]);
        //     printf("%lld\n", f[1][1][0][1][2]);
        //     printf("%lld\n", f[1][0][2][2][2]);
        //     printf("%lld\n", f[1][0][1][2][1]);
        //     printf("%lld\n", f[1][0][1][2][0]);
        // }
    }

    // for (int x = 0; x <= 2; x++)
    //     for (int y = 0; y <= 2; y++)
    //         for (int j = 0; j <= n; j++)
    //             for (int k = 0; k <= n; k++)
    //                 inc(g[j][k], f[n & 1][j][k][x][y]);
    // for (int i = 0; i <= n; i++)
    //     for (int j = 0; j <= n; j++)
    //         printf("%lld%c", g[i][j], " \n"[j == n]);

    for (int x = 0; x <= 2; x++)
        for (int y = 0; y <= 2; y++) {
            int cur = n & 1;
            for (int j = 0; j <= n; j++)
                for (int k = 0; k <= n; k++) {
                    sum[j][k][x][y] = f[cur][j][k][x][y];
                    if (k >= 1) inc(sum[j][k][x][y], sum[j][k - 1][x][y]);
                }
            for (int j = 1; j <= n; j++)
                for (int k = 0; k <= n; k++) 
                    inc(sum[j][k][x][y], sum[j - 1][k][x][y]);
        }
    ll ans = 0;
    for (int x = 0; x <= 2; x++)
        for (int y = 0; y <= 2; y++)
            inc(ans, sum[n][n][x][y]);

    // printf("%lld\n", ans);

    for (int a = 1; a <= 26; a++) 
        for (int j = 0; j <= n; j++)
            for (int k = c[a] + 1; k <= n; k++)
                for (int x = 0; x <= 2; x++)
                    for (int y = 0; y <= 2; y++)
                        sub(ans, f[n & 1][j][k][x][y]);

    // printf("%lld\n", ans);

    for (int a = 1; a <= 26; a++)
        for (int b = a + 1; b <= 26; b++) {
            for (int x = 0; x <= 2; x++)
                for (int y = 0; y <= 2; y++) {
                    // ans += sum[n][n] + sum[c[a]][c[b]] - sum[n][c[b]] - sum[c[a]][n];
                    inc(ans, sum[n][n][x][y]);
                    inc(ans, sum[c[a]][c[b]][x][y]);
                    sub(ans, sum[n][c[b]][x][y]);
                    sub(ans, sum[c[a]][n][x][y]);
                }
        }
    printf("%lld\n", ans);

#ifndef ONLINE_JUDGE
    clock_t ed_clock = clock();
    printf("time = %f ms\n", (double)(ed_clock - st_clock) / CLOCKS_PER_SEC * 1000);
#endif
    return 0;
}