#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
long long fac[N], infac[N];
int n, m;
long long poww(long long b, long long p) {
  if (p == 0) return 1;
  if (p & 1) return (b * poww(b, p - 1)) % m;
  return poww((b * b) % m, p / 2);
}
long long npk(int n, int k) { return (fac[n] * infac[n - k]) % m; }
long long nck(int n, int k) {
  return (((fac[n] * infac[n - k]) % m) * infac[n - k]) % m;
}
int main() {
  cin >> n >> m;
  fac[0] = infac[0] = 1;
  for (int i = 1; i <= n; i++) {
    fac[i] = (i * fac[i - 1]) % m;
    infac[i] = poww(fac[i], m - 2);
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    long long a = n - i + 1;
    a = (a * fac[i]) % m;
    ans = (ans + a * fac[n - i + 1]) % m;
  }
  cout << ans << endl;
}
