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 <set>

using namespace std;

const int mod = 998244353;
const int N = 402;

int add(int x, int y) {
  x += y;
  while (x >= mod)
    x -= mod;
  if (x < 0)
    x += mod;
  return x;
}

int sub(int x, int y) {
  return add(x, -y);
}

int mul(int x, int y) {
  return (x * 1ll * y) % mod;
}

int c[26];
int dp[2][N][N][3][3];  // [compressed_len, num_first_ele, num_second_ele, second_last_ele, last_ele]
int sumDp[N][N];  // [num_first_ele, num_second_ele]
int prefixDp[N][N];
int p1[N][N];
int p2[N][N];
int n;

int main() {
  cin >> n;
  for (int i = 0; i < 26; ++i)
    cin >> c[i];
  // init dp for len 3
  for (int i = 0; i < 26; ++i) {
    for (int j = 0; j < 26; ++j) {
      for (int k = 0; k < 26; ++k) {
        if (i != k) {
          multiset<int> s = {i, j, k};
          dp[1][s.count(0)][s.count(1)][min(2, j)][min(2, k)]++;
        }
      }
    }
  }
  // dp
  for (int i = 4; i <= n; ++i) {
    for (int j = 0; j < N; ++j) {
      for (int k = 0; k < N; ++k) {
        for (int x = 0; x < 3; ++x) {
          for (int y = 0; y < 3; ++y) {
            dp[0][j][k][x][y] = dp[1][j][k][x][y];
            dp[1][j][k][x][y] = 0;
          }
        }
      }
    }
    for (int j = 0; j < N; ++j) {
      for (int k = 0; k < N; ++k) {
        for (int x = 0; x < 3; ++x) {
          for (int y = 0; y < 3; ++y) {
            int cur = dp[0][j][k][x][y];
            if (0 == cur) {
              continue;
            }
            for (int z = 0; z < 3; ++z) {
              int &nw = dp[1][j + (z == 0 ? 1 : 0)][k + (z == 1 ? 1 : 0)][y][z];
              nw = add(nw, mul(cur, (z == 2 ? 24 : 1) - (z == x ? 1 : 0)));
            }
          }
        }
      }
    }
  }
  // sum of dp in the dim of first and second ending character
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      for (int k = 0; k < 3; ++k) {
        for (int l = 0; l < 3; ++l) {
          sumDp[i][j] = add(sumDp[i][j], dp[1][i][j][k][l]);
        }
      }
    }
  }
  // 2d prefix of dp
  for (int i = N - 1; 0 <= i; --i) {
    for (int j = N - 1; 0 <= j; --j) {
      if (i == N - 1) {
        if (j == N - 1) {
          prefixDp[i][j] = sumDp[i][j];
        } else {
          prefixDp[i][j] = add(prefixDp[i][j + 1], sumDp[i][j]);
        }
      } else if (j == N - 1) {
        prefixDp[i][j] = add(prefixDp[i + 1][j], sumDp[i][j]);
      } else {
        prefixDp[i][j] = sub(add(add(prefixDp[i + 1][j], prefixDp[i][j + 1]), sumDp[i][j]) ,prefixDp[i + 1][j + 1]);
      }
    }
  }
  int ans = prefixDp[0][0];
  for (int i = 0; i < 26; ++i) {
    for (int j = 0; j < N; ++j) {
      for (int k = c[i] + 1; k < N; ++k) {
        ans = sub(ans, sumDp[k][j]);
      }
    }
  }
  for (int i = 0; i < 26; ++i) {
    for (int j = 0; j < i; ++j) {
      ans = add(ans, prefixDp[c[i] + 1][c[j] + 1]);
    }
  }
  cout << ans << endl;
  return 0;
}