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