#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
long long a[250005];
int main() {
  long long ans = 0, n, m;
  scanf("%lld%lld", &n, &m);
  a[0] = 1;
  for (long long i = 1; i <= n; i++) a[i] = (a[i - 1] * i) % m;
  ans = 0;
  for (long long i = 1; i <= n; i++) {
    ans += ((n - i + 1) * (a[i] * a[n - i + 1] % m)) % m;
    ans %= m;
  }
  printf("%lld\n", ans);
  return 0;
}
