n,k=list(map(int,input().split()))

print((sum(-~i+i*(n-i)for i in range(k,n+2))%(10**9+7)))
n,k=list(map(int,input().split()))

print(((n-k+2)*((-k-~n)*(n+2*k)+6)//6%(10**9+7)))
n, k = list(map(int, input().split()))
print((sum(-~i + i * (n - i) for i in range(k, n + 2)) % (10**9 + 7)))

n, k = list(map(int, input().split()))
print(((n - k + 2) * ((-k - ~n) * (n + 2 * k) + 6) // 6 % (10**9 + 7)))

-print((sum(-~i + i * (n - i) for i in range(k, n + 2)) % (10**9 + 7))) +print(((n - k + 2) * ((-k - ~n) * (n + 2 * k) + 6) // 6 % (10**9 + 7)))