#include <bits/stdc++.h>
using namespace std;
const int maxn = 250000 + 5;
long long dp[maxn];
int main() {
  long long n, m;
  scanf("%lld %lld", &n, &m);
  dp[0] = dp[1] = 1;
  for (long long i = 2; i <= n; i++) {
    dp[i] = ((dp[i - 1] % m) * (i % m)) % m;
  }
  long long sum = 0;
  for (long long i = 1; i <= n; i++) {
    sum += (((dp[i] % m) * (dp[n - i + 1] % m) % m) * ((n - i + 1) % m)) % m;
  }
  printf("%lld\n", sum % m);
}
