#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
const int N = 1e5 + 100;
int n, m;
long long f[250100], ans;
int main() {
  scanf("%d%d", &n, &m);
  f[1] = 1;
  for (int i = 2; i <= n; i++) f[i] = (f[i - 1] * i) % m;
  for (int i = 1; i <= n; i++) {
    ans += ((long long)(n - i + 1) * f[i] % m * f[n - i + 1] % m);
    ans %= m;
  }
  printf("%lld\n", ans);
  return 0;
}
