from sys import stdin, setrecursionlimit





def main():

    mod = 10 ** 9 + 7

    input = stdin.buffer.readline

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



    mins = [0]

    maxs = [n]

    tmp_min = 0

    tmp_max = n

    for i in range(1, n + 1):

        tmp_min += i

        mins.append(tmp_min)

        tmp_max += n - i

        maxs.append(tmp_max)

    ans = 0

    for i in range(k - 1, n + 1):

        ans += maxs[i] - mins[i] + 1

        ans %= mod

    print((ans % mod))





if __name__ == "__main__":

    setrecursionlimit(10000)

    main()

from sys import stdin, setrecursionlimit





def main():

    mod = 10 ** 9 + 7

    input = stdin.buffer.readline

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

    ans = 0

    for i in range(k, n + 2):

        ans += (n - i + 1) * i + 1

        ans %= mod

    print((ans % mod))





if __name__ == "__main__":

    setrecursionlimit(10000)

    main()

from sys import stdin, setrecursionlimit


def main():
    mod = 10**9 + 7
    input = stdin.buffer.readline
    n, k = list(map(int, input().split()))
    mins = [0]
    maxs = [n]
    tmp_min = 0
    tmp_max = n
    for i in range(1, n + 1):
        tmp_min += i
        mins.append(tmp_min)
        tmp_max += n - i
        maxs.append(tmp_max)
    ans = 0
    for i in range(k - 1, n + 1):
        ans += maxs[i] - mins[i] + 1
        ans %= mod
    print((ans % mod))


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

from sys import stdin, setrecursionlimit


def main():
    mod = 10**9 + 7
    input = stdin.buffer.readline
    n, k = list(map(int, input().split()))
    ans = 0
    for i in range(k, n + 2):
        ans += (n - i + 1) * i + 1
        ans %= mod
    print((ans % mod))


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

-    mins = [0] -    maxs = [n] -    tmp_min = 0 -    tmp_max = n -    for i in range(1, n + 1): -        tmp_min += i -        mins.append(tmp_min) -        tmp_max += n - i -        maxs.append(tmp_max) -    for i in range(k - 1, n + 1): -        ans += maxs[i] - mins[i] + 1 +    for i in range(k, n + 2): +        ans += (n - i + 1) * i + 1