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



MOD = 10 ** 9 + 7



ans = 0

num = 0



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

  num += (i - 1)

  if i >= k:

    # print(num, i, i * n - 2 * num + 1)

    ans += max(i * n - 2 * num + 1, 1) 

    ans = ans % MOD



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

MOD = 10 ** 9 + 7



ans = 0

a = 1



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

  a -= 2 * (i - 1)

  if i >= k:

    ans += (i * n + a)

    ans %= MOD

print(ans)
n, k = list(map(int, input().split()))
MOD = 10**9 + 7
ans = 0
num = 0
for i in range(1, n + 2):
    num += i - 1
    if i >= k:
        # print(num, i, i * n - 2 * num + 1)
        ans += max(i * n - 2 * num + 1, 1)
        ans = ans % MOD
print(ans)

n, k = list(map(int, input().split()))
MOD = 10**9 + 7
ans = 0
a = 1
for i in range(1, n + 2):
    a -= 2 * (i - 1)
    if i >= k:
        ans += i * n + a
        ans %= MOD
print(ans)

-num = 0 +a = 1 -    num += i - 1 +    a -= 2 * (i - 1) -        # print(num, i, i * n - 2 * num + 1) -        ans += max(i * n - 2 * num + 1, 1) -        ans = ans % MOD +        ans += i * n + a +        ans %= MOD