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

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

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

f = lambda i: (n + 1) * i * (i - 1) // 2 - i * (i - 1) * (2 * i - 1) // 6 

print(((n - k + 2 + f(n + 2) - f(k)) % (10**9 + 7)))

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

n, k = list(map(int, input().split()))
f = lambda i: (n + 1) * i * (i - 1) // 2 - i * (i - 1) * (2 * i - 1) // 6
print(((n - k + 2 + f(n + 2) - f(k)) % (10**9 + 7)))

-print((sum(i * (n - i + 1) + 1 for i in range(k, n + 2)) % (10**9 + 7))) +f = lambda i: (n + 1) * i * (i - 1) // 2 - i * (i - 1) * (2 * i - 1) // 6 +print(((n - k + 2 + f(n + 2) - f(k)) % (10**9 + 7)))