import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n,k = na()
mod = 10**9 + 7
ans = 1
for i in range(k, n+1):
  ans += (2*n-i+1)*i//2-i*(i-1)//2+1
  ans %= mod

print(ans)