N = [int(e) for e in input().split()]
nums = []
u = 10**9 + 7
t = 0
s = 0
Min =0
Max =0
for i in range(0,N[1]):
    Min += i
    t = i+1
    Max += N[0] - i
    s = N[0] - i -1
ans = Max - Min + 1
for k in range(N[1]+1,N[0]+2):
    Min += t
    t += 1
    Max += s
    s -= 1
    ans += Max - Min + 1
print(ans%u)