N, K = map(int, input().split())
MOD = 1000000007

min_ = sum([i for i in range(K)])
max_ = sum([i for i in range(N, N - K, -1)])

right = K - 1
left = N - (K - 1)

cnt = 0
for k in range(K, N + 2):
    cnt += max_ - min_ + 1
    right += 1
    left -= 1

    min_ += right
    max_ += left

print(cnt % MOD)
