#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long MOD;
long long add(long long x, long long y) {
  x += y;
  if (x >= MOD) return x - MOD;
  return x;
}
long long mult(long long x, long long y) { return (x * y) % MOD; }
long long bin_pow(long long x, long long p) {
  if (p == 0) return 1;
  if (p & 1) return mult(x, bin_pow(x, p - 1));
  return bin_pow(mult(x, x), p / 2);
}
long long rev(long long x) { return bin_pow(x, MOD - 2); }
const int N = 300300;
int n;
long long f[N], rf[N];
int main() {
  scanf("%d%lld", &n, &MOD);
  f[0] = 1;
  for (int i = 1; i < N; i++) f[i] = mult(f[i - 1], i);
  rf[N - 1] = rev(f[N - 1]);
  for (int i = N - 1; i > 0; i--) rf[i - 1] = mult(rf[i], i);
  long long ans = 0;
  for (int k = 1; k <= n; k++) {
    ans = add(ans, mult(mult(n - k + 1, n - k + 1), mult(f[k], f[n - k])));
  }
  printf("%lld\n", ans);
  return 0;
}
