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;

const int P = 998244353;
int n, c[26], f[210][210][210][3], g[210][210], h[210][210], ways[3][3];

int qp(int x, int y) {
    int z = 1;
    for (; y; y >>= 1, x = 1LL * x * x % P) {
        if (y & 1) z = 1LL * z * x % P;
    }
    return z;
}

int main() {
    scanf("%d", &n);
    for (int i = 0; i < 26; i++) {
        scanf("%d", &c[i]);
    }
    int ans = 1LL * 26 * 26 * qp(25, n - 2) % P;
    auto solve = [&](int x, int y, bool flag) {
        int n1 = n / 2, n2 = n - n1;
        if (flag) {
            for (int i = 1; i <= n / 2 + 1; i++) {
                for (int j = 0; j + j <= i + 1; j++) {
                    for (int k = 0; k + k <= i + 1 && j + k <= i; k++) {
                        memset(f[i][j][k], 0, sizeof(f[i][j][k]));
                    }
                }
            }
            for (int p : {0, 1, 2}) {
                int t = 0;
                if (!p) t = 25 - (y != -1);
                else if (p == 1 || y != -1) t = 1;
                f[1][p == 1][p == 2][p] = t;
            }
            memset(ways, 0, sizeof(ways));
            ways[0][0] = 25 - (y != -1) - 1;
            ways[1][0] = ways[2][0] = 25 - (y != -1);
            ways[0][1] = ways[2][1] = 1;
            ways[0][2] = ways[1][2] = y != -1;
            for (int i = 1; i < n2; i++) for (int j = 0; j + j <= i + 1; j++) {
                for (int k = 0; k + k <= i + 1 && j + k <= i; k++) {
                    for (int p : {0, 1, 2}) if (f[i][j][k][p]) {
                        for (int q : {0, 1, 2}) if (ways[p][q]) {
                            int nj = j + (q == 1), nk = k + (q == 2);
                            f[i + 1][nj][nk][q] = (f[i + 1][nj][nk][q] + 1LL * f[i][j][k][p] * ways[p][q]) % P;
                        }
                    }
                }
            }
            memset(g, 0, sizeof(g));
            memset(h, 0, sizeof(h));
            for (int i = 0; i <= n2; i++) {
                for (int j = n2 - i; ~j; j--) {
                    g[i][j] = g[i][j + 1];
                    for (int p : {0, 1, 2}) {
                        if ((g[i][j] += f[n2][i][j][p]) >= P) g[i][j] -= P;
                    }
                }
            }
            for (int i = 0; i <= n1; i++) {
                for (int j = 0; i + j <= n1; j++) {
                    for (int p : {0, 1, 2}) {
                        if ((h[i][j] += f[n1][i][j][p]) >= P) h[i][j] -= P;
                    }
                }
            }
        }
        int ans = 0, cy = !~y ? -1 : c[y];
        for (int i = c[x] + 1; i <= n; i++) {
            for (int j = 0; j + j <= n1 + 1 && j <= min(i, n1); j++) if (i - j <= n2) {
                for (int k = 0; k + k <= n1 + 1 && j + k <= n1; k++) if (h[j][k]) {
                    if (k <= cy && i - j + cy + 1 - k > n2) continue;
                    ans = (ans + 1LL * h[j][k] * g[i - j][k <= cy ? cy + 1 - k : 0]) % P;
                }
            }
        }
        return ans;
    };
    for (int i = 0; i < 26; i++) {
        ans = (ans - solve(i, -1, i == 0) + P) % P;
    }
    bool fir = 1;
    for (int i = 0; i < 26; i++) {
        for (int j = i + 1; j < 26; j++) if (c[i] + c[j] + 2 <= n) {
            (ans += solve(i, j, fir)) %= P, fir = 0;
        }
    }
    printf("%d\n", ans);
    return 0;
}