Under construction

Still being built. Things may change

Robot Upgrades

Time limit1sMemory limit2048 MB

Summary
Count the ways to set each of N parts to an upgrade level from 0 to M so that, for each i, at most A_i parts reach level i or higher, modulo 998244353.
Level

Hard8 of 10

Topics
Dynamic programming, Combinatorics, Math
Solved
No attempts yet

Problem

The Kingdom of ICPC is under attack by evil balloons! Fortunately, Morgan the robot is ready to defend the kingdom. To strengthen his power, there are NN parts, numbered from 11 to NN, that can be upgraded. Each part can be upgraded between 00 and MM times, inclusive.

To save resources, Morgan's upgrades are subject to MM restrictions, numbered from 11 to MM. For restriction ii, the number of parts upgraded at least ii times must not exceed AiA_i.

Adrian is planning which upgrades to apply to Morgan and wonders how many upgrade configurations satisfy all the restrictions. Two configurations are different if and only if at least one part has a different number of upgrades. Since the answer can be large, find it modulo 998 244 353998\,244\,353.

Input

The first line contains two integers NN and MM (1≤N≤100 0001 \le N \le 100\,000, 1≤M≤101 \le M \le 10). The next line contains MM integers A1,A2,…,AMA_1, A_2, \dots, A_M (1≤Ai≤N1 \le A_i \le N), given in non-increasing order, that is, A1≥A2≥⋯≥AMA_1 \ge A_2 \ge \dots \ge A_M.

Output

Output a single integer: the number of upgrade configurations that satisfy all restrictions, modulo 998 244 353998\,244\,353.

Examples3

  1. Example 1

    Input
    3 5
    2 2 1 1 1
    
    Expected output
    64
    
  2. Example 2

    Input
    1 2
    1 1
    
    Expected output
    3
    
  3. Example 3

    Input
    16 8
    16 16 8 4 4 2 1 1
    
    Expected output
    720246211