M, N = map(int, input().split()) X = [0] + list(map(int, input().split())) + [M + 1] ans = 0 mod = 998244353 for i in range(len(X) - 1): d = X[i + 1] - X[i] - 1 ans += d * (d + 1) * (2 * d + 1) // 6 ans %= mod print(ans)