#include <bits/stdc++.h>
using namespace std;
const int maxn = 25e4 + 5;
long long jie[maxn], mod;
int n;
int main() {
  cin >> n >> mod;
  jie[0] = 1;
  for (int i = 1; i <= n; i++) jie[i] = jie[i - 1] * i % mod;
  long long ans = 0;
  for (int k = 1; k <= n; k++) {
    ans = (ans + (jie[k] * jie[n - k + 1] % mod) * (n - k + 1) % mod) % mod;
  }
  cout << ans << endl;
  return 0;
}
