import sys

## io

IS = lambda: sys.stdin.readline().rstrip()

II = lambda: int(IS())

MII = lambda: list(map(int, IS().split()))

MIIZ = lambda: list([x-1 for x in MII()])

## dp

INIT_VAL = 0

DP2 = lambda d1, d2: [[INIT_VAL]*d2 for _ in range(d1)]

DP3 = lambda d1, d2, d3: [[[INIT_VAL]*d3 for _ in range(d2)] for _ in range(d1)]

from itertools import accumulate as acc

MOD = 10**9+7



def main():

    n, k = MII()

    cnt = 0

    dd = [i for i in range(n+1)]

    # print(dd)

    dd_a = [0]

    for i in range(n+1):

        d = dd_a[i] + dd[i]

        dd_a.append(d)

    # print(dd_a)

    dd_b = [0]

    dd_r = dd[::-1]

    for i in range(n+1):

        d = dd_b[i] + dd_r[i]

        dd_b.append(d)

    # print(dd_b)

    for i in range(k,len(dd_a)):

        cnt += dd_b[i]-(dd_a[i]-1)

    print((cnt%MOD))



if __name__ == '__main__':

    main()

import sys

## io

IS = lambda: sys.stdin.readline().rstrip()

II = lambda: int(IS())

MII = lambda: list(map(int, IS().split()))

MIIZ = lambda: list([x-1 for x in MII()])

## dp

INIT_VAL = 0

DP2 = lambda d1, d2: [[INIT_VAL]*d2 for _ in range(d1)]

DP3 = lambda d1, d2, d3: [[[INIT_VAL]*d3 for _ in range(d2)] for _ in range(d1)]

from itertools import accumulate as acc

MOD = 10**9+7



def main():

    n, k = MII()

    cnt = 0

    dd = [i for i in range(n+1)]

    dd_a = list(acc(dd))

    dd_b = list(acc(dd[::-1]))

    for i in range(k-1,len(dd_a)):

        cnt += dd_b[i]-(dd_a[i]-1)

    print((cnt%MOD))



if __name__ == '__main__':

    main()

import sys

## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list([x - 1 for x in MII()])
## dp
INIT_VAL = 0
DP2 = lambda d1, d2: [[INIT_VAL] * d2 for _ in range(d1)]
DP3 = lambda d1, d2, d3: [[[INIT_VAL] * d3 for _ in range(d2)] for _ in range(d1)]
from itertools import accumulate as acc

MOD = 10**9 + 7


def main():
    n, k = MII()
    cnt = 0
    dd = [i for i in range(n + 1)]
    # print(dd)
    dd_a = [0]
    for i in range(n + 1):
        d = dd_a[i] + dd[i]
        dd_a.append(d)
    # print(dd_a)
    dd_b = [0]
    dd_r = dd[::-1]
    for i in range(n + 1):
        d = dd_b[i] + dd_r[i]
        dd_b.append(d)
    # print(dd_b)
    for i in range(k, len(dd_a)):
        cnt += dd_b[i] - (dd_a[i] - 1)
    print((cnt % MOD))


if __name__ == "__main__":
    main()

import sys

## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list([x - 1 for x in MII()])
## dp
INIT_VAL = 0
DP2 = lambda d1, d2: [[INIT_VAL] * d2 for _ in range(d1)]
DP3 = lambda d1, d2, d3: [[[INIT_VAL] * d3 for _ in range(d2)] for _ in range(d1)]
from itertools import accumulate as acc

MOD = 10**9 + 7


def main():
    n, k = MII()
    cnt = 0
    dd = [i for i in range(n + 1)]
    dd_a = list(acc(dd))
    dd_b = list(acc(dd[::-1]))
    for i in range(k - 1, len(dd_a)):
        cnt += dd_b[i] - (dd_a[i] - 1)
    print((cnt % MOD))


if __name__ == "__main__":
    main()

-    # print(dd) -    dd_a = [0] -    for i in range(n + 1): -        d = dd_a[i] + dd[i] -        dd_a.append(d) -    # print(dd_a) -    dd_b = [0] -    dd_r = dd[::-1] -    for i in range(n + 1): -        d = dd_b[i] + dd_r[i] -        dd_b.append(d) -    # print(dd_b) -    for i in range(k, len(dd_a)): +    dd_a = list(acc(dd)) +    dd_b = list(acc(dd[::-1])) +    for i in range(k - 1, len(dd_a)):