from itertools import permutations, combinations

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

ans = 0
_list = list(range(N+1))
_list.sort(reverse = True)
h = 0
l = 0
cnt = -1

for i in range(N+1):
    h += _list[i]
    cnt += 1
    l += cnt
    if i >= K-1:
        ans += h - l + 1
        
print(ans%(10**9 + 7))