P = 998244353 nn = 1001001 fa = [1] * (nn+1) fainv = [1] * (nn+1) for i in range(nn): fa[i+1] = fa[i] * (i+1) % P fainv[-1] = pow(fa[-1], P-2, P) for i in range(nn)[::-1]: fainv[i] = fainv[i+1] * (i+1) % P N, M = map(int, input().split()) A = [int(a) for a in input().split()] B = [0] * N i = 0 for a in A: while i < a: B[i] = a i += 1 ans = 0 for i in range(N): ans = (ans + fainv[N-i] % P * fa[N-i-1] % P * B[i]) % P print(ans)