#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 = (P(N - 1, K) + (P(N, K) - P(N - 1, K) * 2 + P(N - 2, K)) / 2) % MOD; ll right = P(N, K + 1); cout << (left*way + right) % MOD << endl; return 0; }