P24765 [AtCoder] Alphabet Tiles
普及+
题目描述

Problem Statement

AtCoder Land sells tiles with English letters written on them. Takahashi is thinking of making a nameplate by arranging these tiles in a row.

Find the number, modulo 998244353, of strings consisting of uppercase English letters with a length between 1 and K, inclusive, that satisfy the following conditions:

  • For every integer $i satisfying 1 \leq i \leq 26$, the following holds:
  • Let a_i be the i-th uppercase English letter in lexicographical order. For example, a_1 = A, a_5 = E, a_{26} = Z.
  • The number of occurrences of a_i in the string is between 0 and C_i, inclusive.

Input

The input is given from Standard Input in the following format:
K
$C_1 C_2 \ldots C_{26}$

Output

Print the answer.

Constraints

  • $1 \leq K \leq 1000$
  • $0 \leq C_i \leq 1000$
  • All input values are integers.

Sample Input 1

2
2 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Sample Output 1

10

The 10 strings that satisfy the conditions are A, B, C, AA, AB, AC, BA, BC, CA, CB.

Sample Input 2

358
1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Sample Output 2

64

Sample Input 3

1000
1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000

Sample Output 3

270274035

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
2 2 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
样例输出
10