MOD = int(1e9)+7

def main():

    n, k = list(map(int, input().split()))

    n += 1

    a = [int(i) for i in range(n)]

    s = [0]

    for i in range(n):

        s.append(s[i]+a[i])



    ans = 0 

    for i in range(k, n+1):

        ans += s[n]-s[n-i]-s[i]+1

        ans %= MOD

    print((ans%MOD))

main()
import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

 

def main():

    N, K = list(map(int, readline().split()))

    p = [int(i) for i in range(N+1)]

    s = [0]

    for i in range(N+1):

        s.append(s[i]+p[i])

    ans = 0

    P = int(1e9)+7

    for k in range(K, N+2):

        ans += (s[-1]-s[-k-1])-(s[k]-s[0])+1

        ans %= P

    print(ans)

if __name__ == '__main__':

    main()
MOD = int(1e9) + 7


def main():
    n, k = list(map(int, input().split()))
    n += 1
    a = [int(i) for i in range(n)]
    s = [0]
    for i in range(n):
        s.append(s[i] + a[i])
    ans = 0
    for i in range(k, n + 1):
        ans += s[n] - s[n - i] - s[i] + 1
        ans %= MOD
    print((ans % MOD))


main()

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    N, K = list(map(int, readline().split()))
    p = [int(i) for i in range(N + 1)]
    s = [0]
    for i in range(N + 1):
        s.append(s[i] + p[i])
    ans = 0
    P = int(1e9) + 7
    for k in range(K, N + 2):
        ans += (s[-1] - s[-k - 1]) - (s[k] - s[0]) + 1
        ans %= P
    print(ans)


if __name__ == "__main__":
    main()

-MOD = int(1e9) + 7 +import sys + +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines -    n, k = list(map(int, input().split())) -    n += 1 -    a = [int(i) for i in range(n)] +    N, K = list(map(int, readline().split())) +    p = [int(i) for i in range(N + 1)] -    for i in range(n): -        s.append(s[i] + a[i]) +    for i in range(N + 1): +        s.append(s[i] + p[i]) -    for i in range(k, n + 1): -        ans += s[n] - s[n - i] - s[i] + 1 -        ans %= MOD -    print((ans % MOD)) +    P = int(1e9) + 7 +    for k in range(K, N + 2): +        ans += (s[-1] - s[-k - 1]) - (s[k] - s[0]) + 1 +        ans %= P +    print(ans) -main() +if __name__ == "__main__": +    main()