#include <bits/stdc++.h>
using namespace std;
int const N = 250000;
int fc[N + 1], n, md;
void ad(int &x, int y) {
  if ((x += y) >= md) x -= md;
}
int main() {
  scanf("%d%d", &n, &md);
  fc[0] = 1;
  for (int i = 1; i < (int)(n + 1); ++i) fc[i] = (long long)fc[i - 1] * i % md;
  int an = 0;
  for (int i = 1; i < (int)(n + 1); ++i)
    ad(an,
       (long long)(n + 1 - i) * (n + 1 - i) % md * fc[i] % md * fc[n - i] % md);
  printf("%d\n", an);
}
