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

S1 = 0

S2 = 0

for k in range(1, N+1):

    S1 += k*N - k*(k-1) +1

    S1 %= 10**9 + 7

for k in range(1, K):

    S2 += k*N - k*(k-1) +1

    S2 %= 10**9 + 7

    

S = S1 - S2 + 1

S %= 10**9 +7



print(S)
import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

import numpy as np

MOD = 10 ** 9 + 7



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



k = np.arange(K, N + 2, dtype=np.int64)

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

high = N * k - low

cnt = high - low + 1

print((cnt.sum() % MOD))

N, K = list(map(int, input().split()))
S1 = 0
S2 = 0
for k in range(1, N + 1):
    S1 += k * N - k * (k - 1) + 1
    S1 %= 10**9 + 7
for k in range(1, K):
    S2 += k * N - k * (k - 1) + 1
    S2 %= 10**9 + 7
S = S1 - S2 + 1
S %= 10**9 + 7
print(S)

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

MOD = 10**9 + 7
N, K = list(map(int, read().split()))
k = np.arange(K, N + 2, dtype=np.int64)
low = (k - 1) * k // 2
high = N * k - low
cnt = high - low + 1
print((cnt.sum() % MOD))

-N, K = list(map(int, input().split())) -S1 = 0 -S2 = 0 -for k in range(1, N + 1): -    S1 += k * N - k * (k - 1) + 1 -    S1 %= 10**9 + 7 -for k in range(1, K): -    S2 += k * N - k * (k - 1) + 1 -    S2 %= 10**9 + 7 -S = S1 - S2 + 1 -S %= 10**9 + 7 -print(S) +import sys + +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines +import numpy as np + +MOD = 10**9 + 7 +N, K = list(map(int, read().split())) +k = np.arange(K, N + 2, dtype=np.int64) +low = (k - 1) * k // 2 +high = N * k - low +cnt = high - low + 1 +print((cnt.sum() % MOD))