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>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

const int N = 403;
const int ALP = 26;
const int MOD = 998244353;

int add(int a, int b) {
    if (a + b < MOD) {
        return a + b;
    }
    return a + b - MOD;
}

int sub(int a, int b) {
    if (a >= b) {
        return a - b;
    }
    return a - b + MOD;
}

int mul(int a, int b) {
    return 1ll * a * b % MOD;
}

int n;

int dp1[2][N][2];
int dp1_ps[2][N][2];

int dp2[2][N][N][3];
int dp2_ps[2][N][N][3];

void init() {
    {
        dp1[1][1][0] = 1;
        dp1[1][0][1] = ALP - 1;
        for (int c = 1; c + 1 <= (n + 1) / 2; c++) {
            int w = c & 1;
            int nx = w ^ 1;
            for (int c1 = 0; c1 <= c + 1; c1++) {
                for (int p = 0; p < 2; p++) {
                    dp1[nx][c1][p] = 0;
                }
            }
            for (int c1 = 0; c1 <= c; c1++) {
                for (int p = 0; p < 2; p++) {
                    for (int t = 0; t < 2; t++) {
                        if (t == p) {
                            if (t == 1) {
                                dp1[nx][c1][t] = add(dp1[nx][c1][t], mul(ALP - 2, dp1[w][c1][p]));
                            }
                        } else {
                            if (t == 1) {
                                dp1[nx][c1][t] = add(dp1[nx][c1][t], mul(ALP - 1, dp1[w][c1][p]));
                            } else {
                                dp1[nx][c1 + 1][t] = add(dp1[nx][c1 + 1][t], dp1[w][c1][p]);
                            }
                        }
                    }
                }
            }
        }
        int tn = (n + 1) / 2;
        for (int k = 0; k < 2; k++) {
            for (int c1 = tn; c1 >= 0; c1--) {
                for (int t = 0; t < 2; t++) {
                    dp1_ps[k][c1][t] = add(dp1_ps[k][c1 + 1][t], dp1[k][c1][t]);
                }
            }
        }
    }
    {
        dp2[1][0][0][2] = ALP - 2;
        dp2[1][1][0][0] = 1;
        dp2[1][0][1][1] = 1;
        for (int c = 1; c + 1 <= (n + 1) / 2; c++) {
            int w = c & 1;
            int nx = w ^ 1;
            for (int c1 = 0; c1 <= c + 1; c1++) {
                for (int c2 = 0; c2 + c1 <= c + 1; c2++) {
                    for (int p = 0; p < 3; p++) {
                        dp2[nx][c1][c2][p] = 0;
                    }
                }
            }
            for (int c1 = 0; c1 <= c; c1++) {
                for (int c2 = 0; c1 + c2 <= c; c2++) {
                    for (int p = 0; p < 3; p++) {
                        if (dp2[w][c1][c2][p] == 0) continue;
                        for (int t = 0; t < 3; t++) {
                            if (t == p) {
                                if (t == 2) {
                                    dp2[nx][c1][c2][t] = add(dp2[nx][c1][c2][t], mul(ALP - 3, dp2[w][c1][c2][p]));
                                }
                            } else {
                                if (t == 2) {
                                    dp2[nx][c1][c2][t] = add(dp2[nx][c1][c2][t], mul(ALP - 2, dp2[w][c1][c2][p]));
                                } else {
                                    dp2[nx][c1 + (t == 0)][c2 + (t == 1)][t] = add(dp2[nx][c1 + (t == 0)][c2 + (t == 1)][t], dp2[w][c1][c2][p]);
                                }
                            }
                        }
                    }
                }
            }
        }
        int tn = (n + 1) / 2;
        for (int k = 0; k < 2; k++) {
            for (int c1 = tn; c1 >= 0; c1--) {
                for (int c2 = tn; c2 >= 0; c2--) {
                    for (int t = 0; t < 3; t++) {
                        dp2_ps[k][c1][c2][t] = add(dp2_ps[k][c1 + 1][c2][t], dp2_ps[k][c1][c2 + 1][t]);
                        dp2_ps[k][c1][c2][t] = sub(dp2_ps[k][c1][c2][t], dp2_ps[k][c1 + 1][c2 + 1][t]);
                        dp2_ps[k][c1][c2][t] = add(dp2_ps[k][c1][c2][t], dp2[k][c1][c2][t]);
                    }
                }
            }
        }
    }
}

int get_0(int x) {
    int ans = ALP;
    for (int i = 0; i < x - 1; i++) {
        ans = mul(ans, ALP - 1);
    }
    return ans;
}

int get_1(int F) {
    int ans = 0;
    int fp = (n / 2) & 1;
    int sp = (n - n / 2) & 1;
    for (int iF = 0; iF <= n / 2; iF++) {
        for (int t1 = 0; t1 < 2; t1++) {
            for (int t2 = 0; t2 < 2; t2++) {
                ans = add(ans, mul(dp1[fp][iF][t1], dp1_ps[sp][max(0, F - iF)][t2]));
            }
        }
    }
    return ans;
}

int get_2(int F, int S) {
    int ans = 0;
    int fp = (n / 2) & 1;
    int sp = (n - n / 2) & 1;
    for (int iF = 0; iF <= n / 2; iF++) {
        for (int iS = 0; iS <= n / 2 && iS <= S; iS++) {
            for (int t1 = 0; t1 < 3; t1++) {
                for (int t2 = 0; t2 < 3; t2++) {
                    ans = add(ans, mul(dp2[fp][iF][iS][t1], dp2_ps[sp][max(0, F - iF)][max(0, S - iS)][t2]));
                }
            }
        }
    }
    return ans;
}

int cnt[ALP];

int res0 = 0;
int res1[ALP];
int res2[ALP][ALP];

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n;
    init();
    for (int i = 0; i < ALP; i++) {
        cin >> cnt[i];
    }
    for (int i = 0; i < ALP; i++) {
        for (int j = 0; j < ALP; j++) {
            res2[i][j] = get_2(cnt[i] + 1, cnt[j] + 1);
        }
    }
    for (int i = 0; i < ALP; i++) {
        res1[i] = get_1(cnt[i] + 1);
        for (int j = 0; j < ALP; j++) {
            if (i != j) res1[i] = sub(res1[i], res2[i][j]);
        }
    }
    res0 = mul(get_0(n / 2), get_0(n - n / 2));
    for (int i = 0; i < ALP; i++) {
        res0 = sub(res0, res1[i]);
        for (int j = i + 1; j < ALP; j++) {
            res0 = sub(res0, res2[i][j]);
        }
    }
    cout << res0 << '\n';
}