#include <bits/stdc++.h>
using namespace std;
void Main() {
  for (int m = 1; m <= 6; ++m) {
    using ll = long long;
    ll ret = 0;
    vector<int> a;
    for (int i = 0; i < m; ++i) a.push_back(i + 1);
    do {
      int ans = 0;
      for (int i = 0; i < m; ++i)
        for (int j = i; j < m; ++j) {
          int v0 = 1000000, v1 = -1000000;
          for (int k = i; k <= j; ++k) {
            if (a[k] < v0) v0 = a[k];
            if (a[k] > v1) v1 = a[k];
          }
          int d = v1 - v0;
          if (d == j - i) ans++;
        }
      ret += ans;
      cout << m << ": " << ans << endl;
    } while (std::next_permutation(a.begin(), a.end()));
    cout << "> " << m << ": " << ret << endl;
  }
}
const int N = 250001;
using ll = long long;
vector<ll> A;
ll n, mod;
void init() {
  A.resize(N);
  A[0] = 1;
  A[1] = 1;
  for (int i = 2; i < N; ++i) A[i] = (A[i - 1] * i) % mod;
}
int main() {
  while (cin >> n >> mod) {
    init();
    ll ret = 0;
    for (int d = 0; d < n; ++d) {
      int cnt = d + 1;
      ll ans = (A[cnt] * (n - d)) % mod;
      ans = (ans * A[n - cnt]) % mod;
      ans = (ans * (n - d)) % mod;
      ret = (ret + ans) % mod;
    }
    cout << ret << endl;
  }
}
