# D - Sum of Large Numbers

from itertools import accumulate





def main():

    N, K = list(map(int, input().split()))

    cumsum_left = tuple(accumulate(list(range(N + 1))))

    cumsum_right = tuple(accumulate(reversed(list(range(N + 1)))))

    total = 0

    MOD = 10 ** 9 + 7

    for l, r in zip(cumsum_left[K - 1 :], cumsum_right[K - 1 :]):

        total += r - l + 1

        total %= MOD

    print(total)





if __name__ == "__main__":

    main()

# D - Sum of Large Numbers

from itertools import accumulate





def main():

    N, K = list(map(int, input().split()))

    MOD = 10 ** 9 + 7

    cumsum_left = tuple(accumulate(list(range(N + 1))))

    cumsum_right = tuple(accumulate(reversed(list(range(N + 1)))))

    total = sum(r - l + 1 for l, r in zip(cumsum_left[K - 1 :], cumsum_right[K - 1 :]))

    total %= MOD

    print(total)





if __name__ == "__main__":

    main()

# D - Sum of Large Numbers
from itertools import accumulate


def main():
    N, K = list(map(int, input().split()))
    cumsum_left = tuple(accumulate(list(range(N + 1))))
    cumsum_right = tuple(accumulate(reversed(list(range(N + 1)))))
    total = 0
    MOD = 10**9 + 7
    for l, r in zip(cumsum_left[K - 1 :], cumsum_right[K - 1 :]):
        total += r - l + 1
        total %= MOD
    print(total)


if __name__ == "__main__":
    main()

# D - Sum of Large Numbers
from itertools import accumulate


def main():
    N, K = list(map(int, input().split()))
    MOD = 10**9 + 7
    cumsum_left = tuple(accumulate(list(range(N + 1))))
    cumsum_right = tuple(accumulate(reversed(list(range(N + 1)))))
    total = sum(r - l + 1 for l, r in zip(cumsum_left[K - 1 :], cumsum_right[K - 1 :]))
    total %= MOD
    print(total)


if __name__ == "__main__":
    main()

+    MOD = 10**9 + 7 -    total = 0 -    MOD = 10**9 + 7 -    for l, r in zip(cumsum_left[K - 1 :], cumsum_right[K - 1 :]): -        total += r - l + 1 -        total %= MOD +    total = sum(r - l + 1 for l, r in zip(cumsum_left[K - 1 :], cumsum_right[K - 1 :])) +    total %= MOD