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

MOD = 10**9 + 7

S = N * (N + 1) // 2



ans = 1

for d in range(N + 1):

    if N - d < K:

        break

    mx = S - (d * (d + 1) // 2)

    mi = max(0, (N - d - 1) * ((N - d - 1) + 1) // 2)

    ans += (mx - mi + 1) % MOD

    ans %= MOD

print(ans)
N, K = list(map(int, input().split()))

MOD = 10**9 + 7



ans = 0

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

    base = k * (k - 1) // 2

    mx = base + k + (N - k) * k

    ans += mx - base + 1

    ans %= MOD



print(ans)

N, K = list(map(int, input().split()))
MOD = 10**9 + 7
S = N * (N + 1) // 2
ans = 1
for d in range(N + 1):
    if N - d < K:
        break
    mx = S - (d * (d + 1) // 2)
    mi = max(0, (N - d - 1) * ((N - d - 1) + 1) // 2)
    ans += (mx - mi + 1) % MOD
    ans %= MOD
print(ans)

N, K = list(map(int, input().split()))
MOD = 10**9 + 7
ans = 0
for k in range(K, N + 2):
    base = k * (k - 1) // 2
    mx = base + k + (N - k) * k
    ans += mx - base + 1
    ans %= MOD
print(ans)

-S = N * (N + 1) // 2 -ans = 1 -for d in range(N + 1): -    if N - d < K: -        break -    mx = S - (d * (d + 1) // 2) -    mi = max(0, (N - d - 1) * ((N - d - 1) + 1) // 2) -    ans += (mx - mi + 1) % MOD +ans = 0 +for k in range(K, N + 2): +    base = k * (k - 1) // 2 +    mx = base + k + (N - k) * k +    ans += mx - base + 1