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

mod = int(1e9) + 7

S = 0

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

    S += (N - i + 1) * i + 1

    S %= mod

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

mod = int(1e9) + 7

S = (N * (N + 1) * (N + 2) - (3 * N - 2 * K + 4) * K * (K - 1)) // 6 + N - K + 2

print((S % mod))
N, K = list(map(int, input().split()))
mod = int(1e9) + 7
S = 0
for i in range(K, N + 2):
    S += (N - i + 1) * i + 1
    S %= mod
print(S)

N, K = list(map(int, input().split()))
mod = int(1e9) + 7
S = (N * (N + 1) * (N + 2) - (3 * N - 2 * K + 4) * K * (K - 1)) // 6 + N - K + 2
print((S % mod))

-S = 0 -for i in range(K, N + 2): -    S += (N - i + 1) * i + 1 -    S %= mod -print(S) +S = (N * (N + 1) * (N + 2) - (3 * N - 2 * K + 4) * K * (K - 1)) // 6 + N - K + 2 +print((S % mod))