#include"bits/stdc++.h" using namespace std; using ll = long long; using ld = long double; using pii = pair; using pll = pair; #define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++) #define REP(i,n) FOR((i),0,(n)) #define WAITING(str) int str;std::cin>>str; #define DEBUGING(str) cout<< #str << " " str<> N >> K; ll left = (N - 1)*N / 2 % MOD; ll way = ( (N == K ? 0 : P(N - 1, K)) + (P(N, K) - P(N - 1, K) * 2 + P(N - 2, K)) / 2 ) % MOD; ll right = N == K ? 0 : P(N, K + 1) % MOD; ll res = (left*way%MOD + right) % MOD; cout << (res + MOD) % MOD << endl; return 0; }