def n0():return int(eval(input()))

def n1():return [int(x) for x in input().split()]

def n2(n):return [int(eval(input())) for _ in range(n)]

def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]



n,k=n1()



down=[0]*(n+1)

up=[0]*(n+1)

up[0]=n

ans=0 if k>1 else n+1

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

    down[i]=down[i-1]+i

    up[i]=up[i-1]+(n-i)

    if i>=k-1:

        ans+=up[i]-down[i]+1

print((ans%(10**9+7)))


def s0():return eval(input())

def s1():return input().split()

def s2(n):return [eval(input()) for x in range(n)]

def s3(n):return [[input().split()] for _ in range(n)]

def n0():return int(eval(input()))

def n1():return [int(x) for x in input().split()]

def n2(n):return [int(eval(input())) for _ in range(n)]

def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]



n,k=n1()

 

down=[0]*(n+1)

up=[0]*(n+1)

up[0]=n

ans=0 if k>1 else n+1

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

    down[i]=down[i-1]+i

    up[i]=up[i-1]+(n-i)

    if i>=k-1:

        ans+=up[i]-down[i]+1

print((ans%(10**9+7)))
def n0():
    return int(eval(input()))


def n1():
    return [int(x) for x in input().split()]


def n2(n):
    return [int(eval(input())) for _ in range(n)]


def n3(n):
    return [[int(x) for x in input().split()] for _ in range(n)]


n, k = n1()
down = [0] * (n + 1)
up = [0] * (n + 1)
up[0] = n
ans = 0 if k > 1 else n + 1
for i in range(1, n + 1):
    down[i] = down[i - 1] + i
    up[i] = up[i - 1] + (n - i)
    if i >= k - 1:
        ans += up[i] - down[i] + 1
print((ans % (10**9 + 7)))

def s0():
    return eval(input())


def s1():
    return input().split()


def s2(n):
    return [eval(input()) for x in range(n)]


def s3(n):
    return [[input().split()] for _ in range(n)]


def n0():
    return int(eval(input()))


def n1():
    return [int(x) for x in input().split()]


def n2(n):
    return [int(eval(input())) for _ in range(n)]


def n3(n):
    return [[int(x) for x in input().split()] for _ in range(n)]


n, k = n1()
down = [0] * (n + 1)
up = [0] * (n + 1)
up[0] = n
ans = 0 if k > 1 else n + 1
for i in range(1, n + 1):
    down[i] = down[i - 1] + i
    up[i] = up[i - 1] + (n - i)
    if i >= k - 1:
        ans += up[i] - down[i] + 1
print((ans % (10**9 + 7)))

+def s0(): +    return eval(input()) + + +def s1(): +    return input().split() + + +def s2(n): +    return [eval(input()) for x in range(n)] + + +def s3(n): +    return [[input().split()] for _ in range(n)] + +