#include #include #include using namespace std; using ll = long long; #include using namespace atcoder; #define rep(i, n) for (int i = 0; i< (int)(n); i++) using mint = modint998244353; mint solve(ll a){ mint res = a; res *= (a+1); res *= (2*a + 1); res /= (mint)6; return res; } int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); ll m; int n; cin >> m >> n; if(n == 0){ mint ans = m; ans *= (m+1); ans *= (2*m + 1); ans /= (mint)6; cout << ans.val() << endl; return 0; } vector x(n); rep(i, n)cin >> x[i]; mint score = (mint)0; rep(i, n){ if(i == 0){ score += solve(x[i] - 1); continue; } score += solve(x[i] - x[i-1] - 1); } score += solve(m - x[n-1]); cout << score.val() << endl; return 0; }