#include #define forn(i,s,t) for(int i = (s); i <= (t); ++i) #define form(i,s,t) for(int i = (s); i >= (t); --i) #define rep(i,s,t) for(int i = (s); i < (t); ++i) using namespace std; const int N = 2e5 + 5, Mod = 1e9 + 7; namespace Modint { struct Mint { int res; Mint() {} Mint(int _r) : res(_r) {} inline friend Mint operator + (const Mint& A, const Mint& B) { return Mint((A.res + B.res >= Mod) ? (A.res + B.res - Mod) : (A.res + B.res)); } inline friend Mint operator - (const Mint& A, const Mint& B) {return A + Mint(Mod - B.res); } inline friend Mint operator * (const Mint& A, const Mint& B) {return Mint(1ll * A.res * B.res % Mod); } inline friend Mint& operator += (Mint& A, const Mint& B) {return A = A + B; } inline friend Mint& operator -= (Mint& A, const Mint& B) {return A = A - B; } inline friend Mint& operator *= (Mint& A, const Mint& B) {return A = A * B; } inline friend Mint q_pow(Mint p, int k = Mod - 2) { Mint res(1); for (; k; k >>= 1, p *= p) (k & 1) && (res *= p, 0); return res; } } ; } using Modint :: Mint; Mint fac[N], ifac[N]; inline void table(int n) { fac[0] = Mint(1); forn (i, 1, n) fac[i] = fac[i - 1] * Mint(i); ifac[n] = q_pow(fac[n]); form (i, n - 1, 0) ifac[i] = ifac[i + 1] * Mint(i + 1); } inline bool check(int n, int r) {return n - r >= 0 && n >= 0 && r >= 0; } inline Mint C(int n, int r) { if (!check(n, r)) return Mint(0); return fac[n] * ifac[r] * ifac[n - r]; } int n, k; int main() { scanf("%d%d", &n, &k), table(n); Mint res(0), tmp(1); int l = 0, r = 0; int ll = max(k - n, 0), rr = max(k - 1, 0) - 1; while (r <= rr) ++r, tmp *= Mint(r); while (l <= ll) (l && (tmp *= q_pow(Mint(l)), 0)), ++l; // printf("[%d, %d] %d\n", l, r, tmp.res); forn (a, 1, n) { ll = a + k - n, rr = a + k - 1; // printf("%d %d\n", a + k - 1, n); if (check(a + k - 1, n)) { while (r < rr) ++r, tmp *= Mint(r); while (l < ll) tmp *= q_pow(Mint(l)), ++l; } else continue ; // printf("[%d, %d] %d %d %d\n", l, r, tmp.res, C(n - 1, a - 1).res, ifac[n].res); // printf("%d\n", (C(n - 1, a - 1) * tmp * ifac[n]).res); res += C(n - 1, a - 1) * tmp * ifac[n]; } printf("%d\n", res.res); return 0; }