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;

template <typename T> 
void add(T &x, T y) {
    x = (x + y) % P;
}

int main() {
    int n;
    cin >> n;

    vector<int> c(26);
    for (int i = 0; i < 26; ++i) {
        cin >> c[i];
    }

    vector<vector<vector<vector<long long> > > > f(n + 1, vector<vector<vector<long long> > > (n + 1, vector<vector<long long> > (2, vector<long long> (2))));
    f[0][0][0][0] = 1;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j <= i; ++j) {
            for (int x = 0; x < 2; ++x) {
                for (int y = 0; y < 2; ++y) {
                    if (i > 1 && x == 0) {
                        add(f[i + 1][j][y][0], f[i][j][x][y] * 24);
                    } else {
                        add(f[i + 1][j][y][0], f[i][j][x][y] * 25);
                    }
                    if (x != 1) {
                        add(f[i + 1][j + 1][y][1], f[i][j][x][y]);
                    }
                }
            }
        }
    }

    vector<vector<vector<vector<vector<long long> > > > > dp(2, vector<vector<vector<vector<long long> > > > (n + 1, vector<vector<vector<long long> > > (n + 1, vector<vector<long long> > (3, vector<long long> (3)))));

    int cur = 0;
    dp[0][0][0][0][0] = 1;

    for (int i = 0; i < n; ++i) {
        cur ^= 1;
        for (int j = 0; j <= i + 1; ++j) {
            for (int k = 0; k <= i + 1; ++k) {
                for (int x = 0; x < 3; ++x) {
                    for (int y = 0; y < 3; ++y) {
                        dp[cur][j][k][x][y] = 0;
                    }
                }
            }
        }
        for (int j = 0; j <= i; ++j) {
            for (int k = 0; k <= i - j; ++k) {
                for (int x = 0; x < 3; ++x) {
                    for (int y = 0; y < 3; ++y) {
                        if (i > 1 && x == 0) { 
                            add(dp[cur][j][k][y][0], dp[cur ^ 1][j][k][x][y] * 23 % P); 
                        } else {
                            add(dp[cur][j][k][y][0], dp[cur ^ 1][j][k][x][y] * 24 % P);
                        } 
                        if (x != 1) {
                            add(dp[cur][j + 1][k][y][1], dp[cur ^ 1][j][k][x][y]);
                        }
                        if (x != 2) {
                            add(dp[cur][j][k + 1][y][2], dp[cur ^ 1][j][k][x][y]);
                        }
                    }
                }
            }
        }       
    }

    long long ans = 26 * 26;
    for (int i = 2; i < n; ++i) {
        ans = ans * 25 % P;
    }

    for (int i = 0; i < 26; ++i) {
        for (int j = c[i] + 1; j <= n; ++j) {
            for (int x = 0; x < 2; ++x) {
                for (int y = 0; y < 2; ++y) {
                    ans = (ans - f[n][j][x][y] + P) % P;
                }
            }
        }
    }

    for (int i = 0; i < 26; ++i) {
        for (int j = i + 1; j < 26; ++j) {
            for (int x = c[i] + 1; x <= n; ++x) {
                for (int y = c[j] + 1; y <= n; ++y) {
                    for (int a = 0; a < 3; ++a) {
                        for (int b = 0; b < 3; ++b) {
                            add(ans, dp[cur][x][y][a][b]); 
                        }
                    }  
                }
            } 
        }
    }

    cout << ans << '\n';

    return 0;
}