const val mod = 1000000007

fun main() {
	val (n,k) = readLine()!!.split(" ").map {it.toInt()}
	val a = LongArray(n+1) {it.toLong()}
	for(i in 1..n)
		a[i] = (a[i]+a[i-1])%mod

	(k-1..n).map {
		(a[n]-a.elementAtOrElse(n-1-it) {0}-a[it]+1+mod*2)%mod
	}.fold(0L) {a,b-> (a+b)%mod}
			.let {println(it)}
}
