import java.io.*; import java.util.*; import java.util.function.*; import java.util.stream.*; public class Main { static final int MOD = 998244353; static final long DIV6 = pow(6, MOD - 2); public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); long m = sc.nextLong(); int n = sc.nextInt(); long ans = 0; long prev = 0; while (n-- > 0) { long x = sc.nextLong(); ans += calc(x - prev - 1); ans %= MOD; prev = x; } ans += calc(m - prev); ans %= MOD; System.out.println(ans); } static long calc(long x) { if (x >= MOD) { return calc(x % MOD); } else { return x * (x + 1) % MOD * (2 * x % MOD + 1) % MOD * DIV6 % MOD; } } static long pow(long x, int p) { if (p == 0) { return 1; } else if (p % 2 == 0) { return pow(x * x % MOD, p / 2); } else { return pow(x, p - 1) * x % MOD; } } } class Scanner { BufferedReader br; StringTokenizer st = new StringTokenizer(""); public Scanner() { try { br = new BufferedReader(new InputStreamReader(System.in)); } catch (Exception e) { } } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } public String next() { try { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } } catch (Exception e) { e.printStackTrace(); } finally { return st.nextToken(); } } }