import numpy as np



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

MOD = 10 ** 9 + 7

ref = np.array(list(range(n + 1)), dtype='int64')



ans = 0



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

    min_sum = (ref[i - 1] * (ref[i - 1] + 1)) // 2

    max_sum = (n + ref[-i]) * (n - ref[-i] + 1) // 2

    ans += max_sum - min_sum + 1

    ans %= MOD



print(ans)
import numpy as np



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

MOD = 10 ** 9 + 7

ref = np.array(list(range(n + 1)), dtype='int64')



max_sum = np.sum(ref[-k + 1:])

min_sum = np.sum(ref[:k - 1])

if k == 1:

    max_sum = min_sum = 0

ans = 0



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

    min_sum += ref[i - 1]

    max_sum += ref[-i]

    ans += max_sum - min_sum + 1

    ans %= MOD



print(ans)

import numpy as np

n, k = list(map(int, input().split()))
MOD = 10**9 + 7
ref = np.array(list(range(n + 1)), dtype="int64")
ans = 0
for i in range(k, n + 2):
    min_sum = (ref[i - 1] * (ref[i - 1] + 1)) // 2
    max_sum = (n + ref[-i]) * (n - ref[-i] + 1) // 2
    ans += max_sum - min_sum + 1
    ans %= MOD
print(ans)

import numpy as np

n, k = list(map(int, input().split()))
MOD = 10**9 + 7
ref = np.array(list(range(n + 1)), dtype="int64")
max_sum = np.sum(ref[-k + 1 :])
min_sum = np.sum(ref[: k - 1])
if k == 1:
    max_sum = min_sum = 0
ans = 0
for i in range(k, n + 2):
    min_sum += ref[i - 1]
    max_sum += ref[-i]
    ans += max_sum - min_sum + 1
    ans %= MOD
print(ans)

+max_sum = np.sum(ref[-k + 1 :]) +min_sum = np.sum(ref[: k - 1]) +if k == 1: +    max_sum = min_sum = 0 -    min_sum = (ref[i - 1] * (ref[i - 1] + 1)) // 2 -    max_sum = (n + ref[-i]) * (n - ref[-i] + 1) // 2 +    min_sum += ref[i - 1] +    max_sum += ref[-i]