## https://yukicoder.me/problems/no/2940 MOD = 998244353 inv6 = pow(6, MOD - 2, MOD) def sigma_n2(n): ans = (n * (n + 1) )% MOD ans *= (2 * n + 1) % MOD ans %= MOD ans *= inv6 ans %= MOD return ans def main(): M, N = map(int, input().split()) X = list(map(int, input().split())) X_ = [0] + X + [M + 1] answer = 0 for i in range(len(X_) - 1): x0 = X_[i] x1 = X_[i + 1] if x1 - x0 > 1: n = x1 - x0 - 1 a = sigma_n2(n) answer += a answer %= MOD print(answer) if __name__ == "__main__": main()