Under construction

Still being built. Things may change

K-minsum of Permutations

Time limit2sMemory limit512 MB

Summary
Sum the K-minsum over all N! permutations, where K-minsum adds the minimum of every contiguous block of length at least K+1.
Level

Hard8 of 10

Topics
Combinatorics, Math
Solved
No attempts yet

Problem

A permutation of length NN is a sequence built from the NN integers 11 through NN, each used exactly once. No value repeats, so there are N!N! permutations of length NN.

Write the elements of a permutation AA in order as A1,A2,…,ANA_1, A_2, \dots, A_N. The K-minsum of AA is

K-minsum(A)=∑i=1N∑j=i+KNmin⁡(Ai,Ai+1,…,Aj)\text{K-minsum}(A) = \sum_{i=1}^{N} \sum_{j=i+K}^{N} \min(A_i, A_{i+1}, \dots, A_j)

where min⁡\min returns the smallest of the listed numbers. It adds up the minimum of every contiguous block whose length is at least K+1K+1. When i+Ki+K is greater than NN the inner sum is empty and contributes 00.

You are given NN and KK. Compute the K-minsum of each of the N!N! permutations of length NN and add the results together.

Input

The first line contains the permutation length NN and an integer KK, separated by a space. (1≤N≤1061 \le N \le 10^6, 0≤K≤N0 \le K \le N)

Output

Print on one line the sum of the K-minsum over all N!N! permutations of length NN, modulo 1,000,000,007.

Examples6

  1. Example 1

    Input
    1 1
    
    Expected output
    0
    
  2. Example 2

    Input
    2 0
    
    Expected output
    8
    
  3. Example 3

    Input
    3 1
    
    Expected output
    22
    
  4. Example 4

    Input
    5 1
    
    Expected output
    1908
    
  5. Example 5

    Input
    8 2
    
    Expected output
    1435680
    
  6. Example 6

    Input
    13 3
    
    Expected output
    880193815