#include <bits/stdc++.h>
using namespace std;
const int N = 250005;
int n, mod, fact[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> mod;
  fact[0] = 1;
  for (int i = 1; i < N; i++) {
    fact[i] = 1LL * fact[i - 1] * i % mod;
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = (ans + 1LL * fact[i] * fact[n - i + 1] % mod * (n - i + 1)) % mod;
  }
  cout << ans << endl;
}
