#include <bits/stdc++.h>
using namespace std;
long long fact[250001] = {0};
void ini(long long m) {
  fact[0] = 1;
  for (int i = 1; i < 250001; i++) fact[i] = (fact[i - 1] * i) % m;
}
int main() {
  long long n, m;
  cin >> n >> m;
  ini(m);
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    long long r = (fact[i] * fact[n - i]) % m;
    r = (r * (n - i + 1) % m);
    r = r = (r * (n - i + 1) % m);
    ans = (ans + r) % m;
  }
  cout << ans << endl;
  return 0;
}
