n,k = map(int, input().split())
m = 1000000007
ans = []
for i in range(1,n+2):
    ans_min = (0+(i-1))*i*0.5
    ans_max = ((n+1-i)+n)*i*0.5
    ans.append(ans_max-ans_min+1)
ans_wa = [ans[0]]
for i in range(1,n+1):
    ans_wa.append(ans_wa[i-1]+ans[i])
print(int((ans_wa[n]-ans_wa[k-2])%m))