#include using namespace std; #include using mint = atcoder::modint998244353; #define rep(i, a, b) for (int i = a; i < b; i++) mint solve(int N, vector A){ vector fact(N + 1, 1); rep(i, 1, N + 1) fact[i] = fact[i - 1] * i; if (N <= 2){ if ((int)A.size() & 1) return 0; return fact[N]; } vector p(N); int c = 1; for (auto x : A){ p[x - 1] = 1; if (x == 1 || x == N) c *= -1; } vector dp(N); p[0] = 1, p[N - 1] = 1; dp[0] = 1; auto f = [&](auto self, int l, int r) -> void { if (l + 1 == r){ if (p[l]) dp[l] *= -2; else dp[l] = 0; return; } int m = (l + r) / 2; self(self, l, m); vector Y(r - l); rep(i, 0, r - l) Y[i] = fact[i + 1]; vector X(m - l); rep(i, l, m) X[i - l] = dp[i]; auto Z = atcoder::convolution(X, Y); rep(i, m, r) dp[i] += Z[i - l]; self(self, m, r); }; f(f, 0, N); mint ans = (fact[N] + dp[N - 1] / 4) / 2; if (c == -1) ans = fact[N] - ans; return ans; } int main(){ std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int N, M; cin >> N >> M; vector A(M); rep(i, 0, M) cin >> A[i]; cout << solve(N, A).val() << "\n"; }