#include <bits/stdc++.h>
using namespace std;
int n, mod;
long long f[250010];
long long mult(long long a, long long b) {
  long long ans = 1;
  ans = ((a % mod) * (b % mod)) % mod;
  return ans;
}
int main() {
  cin >> n >> mod;
  f[0] = 1;
  for (int i = 1; i <= n; i++) {
    f[i] = mult(i, f[i - 1]);
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += mult(n - i + 1, mult(f[i], f[n - i + 1]));
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}
