m,n=map(int,input().split()) A=[0]+list(map(int,input().split())) A.append(m+1) n+=2 ans=0 for i in range(1,n): ans+=(A[i]-A[i-1]-1)*(A[i]-A[i-1])*(2*(A[i]-A[i-1])-1)//6 ans%=998244353 print(ans)