def II() -> int : return int(input()) def MI() -> int : return map(int, input().split()) def TI() -> tuple[int] : return tuple(MI()) def LI() -> list[int] : return list(MI()) class fenwick_tree(): n=1 data=[0 for i in range(n)] def __init__(self,N): self.n=N self.data=[0 for i in range(N)] def add(self,p,x): assert 0<=p0): s+=self.data[r-1] r-=r&-r return s mod = 998244353 m,n = MI() x = LI() x = [0] + x + [m+1] # print(x) ans = 0 for i in range(1,n+2): d = x[i]-x[i-1]-1 # print(d) ans += pow(6,-1,mod)*d*(d+1)%mod*(2*d+1)%mod print(ans%mod)