N, K = map(int, input().split())
MAX = 10 ** 9 + 7

res = 0

def calc_sum(l, r):
  return ((l+r) * (r-l+1)) // 2

for i in range(K, N+2):
  low = calc_sum(0,i-1)
  high = calc_sum(N-i+1,N)
  res = (res + (high-low+1)) % MAX

print(res)