Inverse Problem

아직 제출이 없습니다시간 제한1초메모리 제한1024 MB

문제

You are given an integer NN and an integer sequence XX of length MM. Count, modulo 998244353998244353, the number of permutations P=(P_1,P_2,,P_N)P = (P\_1,P\_2,\ldots,P\_N) of (1,2,,N)(1,2,\ldots,N) that satisfy the following condition:

  • The lexicographically smallest subsequence of PP of length MM coincides with XX.

입력

The first line contains integers NN (1N2500001 \leq N \leq 250000) and MM (1MN1 \leq M \leq N).

The second line contains integers X_1,X_2,,X_MX\_1,X\_2,\ldots,X\_M (1X_iN1 \leq X\_i \leq N, X_iX_jX\_i \neq X\_j for all iji \neq j).

출력

Print the answer.