#include <bits/stdc++.h>
using namespace std;
const long long N = 3e5 + 11;
long long fact[N];
long long n, m;
void compute() {
  fact[0] = 1;
  for (long long i = 1; i < N; ++i) fact[i] = (fact[i - 1] * i) % m;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  compute();
  long long ans = 0;
  for (long long i = 1; i <= n; ++i) {
    long long val = fact[i];
    val = (val * (n - i + 1)) % m;
    val = (val * (n - i + 1)) % m;
    val = (val * fact[n - i]) % m;
    ans = (ans + val) % m;
  }
  cout << ans;
  return 0;
}
