#include <bits/stdc++.h>
using namespace std;
const double PI = 3.1415926535897932384626433;
int MOD = 0;
int pl(int v1, int v2) {
  int res = v1 + v2;
  if (res < 0)
    res += MOD;
  else if (res >= MOD)
    res -= MOD;
  return res;
}
int mul(const int v1, const int v2) { return (int)((1LL * v1 * v2) % MOD); }
const int N = 250007;
vector<int> fac(N);
void initFac() {
  fac[1] = 1;
  for (int i = 2; i < N; i++) {
    fac[i] = mul(fac[i - 1], i);
  }
}
void solve() {
  int n;
  cin >> n;
  ;
  cin >> MOD;
  if (n == 1) {
    cout << 1 << endl;
    return;
  }
  initFac();
  int ans = mul(fac[n], n);
  ans = pl(ans, fac[n]);
  for (int len = 2; len < n; len++) {
    int lans = n - len + 1;
    lans = mul(lans, fac[len]);
    lans = mul(lans, n - len + 1);
    lans = mul(lans, fac[n - len]);
    ans = pl(ans, lans);
  }
  cout << ans << endl;
}
int main() {
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  solve();
}
