#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using lint = long long; using ld = long double; using pint = pair; using plint = pair; #define MOD 1000000007LL #define INF 1000000000LL #define EPS 1e-10 #define FOR(i,n,m) for(lint i=n;i<(int)m;i++) #define REP(i,n) FOR(i,0,n) #define DUMP(a) REP(d,a.size()){cout<> n >> k; lint tmp1 = 1, tmp2 = 1; REP(i, k) { tmp1 *= (n - 1 - i); tmp1 %= MOD; } REP(i, k - 2) { tmp2 *= (n - 2 - i); tmp2 %= MOD; } lint ans = 0; FOR(i, 1, n + 1) { ans += i * tmp1; ans %= MOD; ans += (i * (k * (k - 1) / 2) % MOD) * tmp2; ans %= MOD; } cout << ans << endl; return 0; } /* --------------------------------------- */