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