CodeEff/ECCO huggingface dataset:
# Original solution
a,b=list(map(int,input().split()))
wa=lambda a,b:(a+b)*(b-a+1)//2
print((sum([wa(a+2-i,a+1)-wa(0,i)+1for i in range(b,a+2)])%(10**9+7)))

# Optimized solution
from math import comb as c
a,b=list(map(int,input().split()))
print((((c(a+2,2)+1)*(a+2-b)-c(a+3-b,3)-c(a+3,3)+c(b+1,3))%(10**9+7)))
# Original solution
P = 10 ** 9 + 7
N, K = list(map(int, input().split()))

L = N + 1  # 数列の長さ 

count = 0
table = [i for i in range(N + 1)]  # 0 ~ Nまでの数列

cusum = [0] * (L + 1)

for i in range(L):
  cusum[i + 1] = cusum[i] + table[i]

while K <= L:
  # K個選んだときの最大値 - 最小値 + 1
  count += (cusum[L] - cusum[L - K]) - cusum[K] + 1
  count %= P
  K += 1

print(count)


# Optimized solution
P = 10 ** 9 + 7
N, K = list(map(int, input().split()))
L = N + 1  # 数列の長さ

cusum = [0] * (L + 1)

for i in range(L):
  cusum[i + 1] = cusum[i] + (i + 1)
  
total = 0

for k in range(K, L + 1):
  total += (cusum[L] - cusum[L - k]) - cusum[k] + 1

print((total % P))
# Original solution
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,k = LI()
ans = 0
tmp = n*(n-1)//2
l = k*(k-1)//2
r = ((n-k+1)+n)*k//2
tmp = n-k
tmp2 = k
for i in range(k,n+2):
    ans += r-l+1
    ans %= mod
    l += tmp2
    r += tmp
    tmp2 += 1
    tmp -= 1
print(ans)

# Optimized solution
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,k = LI()
ans = 0
l = k*(k-1)//2
r = ((n-k+1)+n)*k//2
dl = k
dr = n-k
for i in range(k,n+2):
    ans += r-l+1
    ans %= mod
    l += dl
    r += dr
    dl += 1
    dr -= 1
print(ans)
# Original solution
mod=10**9+7
n,k=list(map(int,input().split()))
ans=(n+1)*(n+k+1)*(n-k+2)//2-(n+1)*(n+2)*(2*n+3)//6+k*(k-1)*(2*k-1)//6+(n-k+2)
ans%=mod
print(ans)

# Optimized solution
mod=10**9+7
n,k=list(map(int,input().split()))
ans=(n+1)*( (n+k+1)*(n-k+2)/2 - (n+2)*(2*n+3)/6 )+k*(k-1)*(2*k-1)/6+(n-k+2)
ans=round(ans)%mod
print(ans)
# Original solution
#n=int(input())
n,k=list(map(int,input().split()))
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

mod=10**9+7
ans=0
for kval in range(k,n+2):
    mx=kval*(2*n-kval+1)//2
    mn=kval*(kval-1)//2
    add=mx-mn+1
    ans=(ans+add) % mod

print(ans)



# Optimized solution
#l=int(input())
n,k=list(map(int,input().split()))
#pl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

mod=10**9+7
total=0

for m in range(k,n+2):
    add=m*(n-m+1)+1
    total=(total+add)%mod
print(total)
# Original solution
n,k = list(map(int,input().split()))
mod = 10**9+7
ans = 0
for i in range(k,n+2):
    ans += i*(n-i+1)+1
    ans %= mod
print(ans)

# Optimized solution
n,k = list(map(int,input().split()))
mod = 10**9+7
print((((-(2*(n+1)**3+3*(n+1)**2+n+1)//6)+(n*(n+1)**2+n*(n+1))//2+((n+1)**2+n+1)//2-((k-1)*n+(k-1)**2*n)//2+n+(k+2*(k-1)**3+3*(k-1)**2-1)//6-(k+(k-1)**2-1)//2-k+2) % mod))
# Original solution
import sys
n,k = list(map(int,sys.stdin.buffer.read().split()))
mod = 10**9+7
print((((n**3+3*n**2+8*n+2*(k-1)**3-8*(k-1)-3*(k-1)**2*n-3*(k-1)*n)//6+1) % mod))

# Optimized solution
n,k = list(map(int,input().split()))
print((((-(2*(n+1)**3+3*(n+1)**2+n+1)//6)+(n*(n+1)**2+n*(n+1))//2+((n+1)**2+n+1)//2-((k-1)*n+(k-1)**2*n)//2+n+(k+2*(k-1)**3+3*(k-1)**2-1)//6-(k+(k-1)**2-1)//2-k+2)%(10**9+7)))
# Original solution
n,k=list(map(int,input().split()))
ans=0
mod=10**9+7
b=[0]+[i for i in range(n+1)]
for i in range(1,n+2):
    b[i]+=b[i-1]

for i in range(k,n+2):
    ans+=b[n+1]-b[n-i+1]-b[i]+1
    ans%=mod
print(ans)

# Optimized solution
n,k=list(map(int,input().split()))
ans=0
mod=10**9+7
for i in range(k,n+2):
    ans+=(2*n-i+1)*i//2-i*(i-1)//2+1
    ans%=mod
print(ans)
# Original solution
n,k=list(map(int,input().split()))
ans=0
mod=10**9+7
for i in range(k,n+2):
    ans+=(2*n-i+1)*i//2-i*(i-1)//2+1
    ans%=mod
print(ans)

# Optimized solution
n,k=list(map(int,input().split()))
ans=0
mod=10**9+7
for i in range(k,n+2):
    ans+=(n-i+1)*i+1
    ans%=mod
print(ans)
# Original solution
n,k=list(map(int,input().split()))
ans=0
mod=10**9+7
for i in range(k,n+2):
    ans+=(n-i+1)*i+1
    ans%=mod
print(ans)

# Optimized solution
n,k=list(map(int,input().split()))
print(((n*(n+1)*(n+2)//6-(3*n-2*k+4)*(k-1)*k//6-k+n+2)%(10**9+7)))
# Original solution
n,k=list(map(int,input().split()))
mod=10**9+7
ans=0
for i in range(k,n+2):
  down=i*(i-1)//2
  up=n*(n+1)//2-(n-i)*(n-i+1)//2
  ans+=up-down+1
  ans%=mod
print(ans)

# Optimized solution
n,k=list(map(int,input().split()))
mod=10**9+7
ans=0
for kk in range(k,n+2):
  mi=kk*(kk-1)//2
  ma=n*(n+1)//2-(n-kk)*(n-kk+1)//2
  ans+=ma-mi+1
  ans%=mod
print(ans)
# Original solution
MOD = 1000000007
n, k = list(map(int, input().split()))

n_li = list(range(n+1))

ans = 0

while(k <= n+1):
    p = (k - 1) * k / 2
    q = ((n + n - k + 1) * k) / 2

    ans += q - p + 1
    ans %= MOD
    k += 1

print((int(ans)))


# Optimized solution
MOD = 1000000007
n, k = list(map(int, input().split()))

n_li = list(range(n+1))

ans = 0

for i in range(k, n+2):
    p = (k - 1) * k / 2
    q = ((n + n - k + 1) * k) / 2

    ans += q - p + 1
    ans %= MOD
    k += 1

print((int(ans)))
# Original solution
N, K = list(map(int, input().split()))

MOD = 10**9 + 7

ans = 0

# 選ぶ個数で場合分け
# 選べる個数はK,K+1,K+2,...,N+1

# 等差数列の和S
# 項数n, 初項a,末項l,公差d
# S=(n/2)*(a+l)
# S=(n/2)*{2a+(n-1)d}
# 0+1+2+...（項数=i）

for i in range(K, N + 2):
    min_sum = i * (i - 1) // 2  # 0+1+...(項数=i)
    max_sum = (2 * N - i + 1) * i // 2  # N+(N-1)+...(項数=i)
    ans += max_sum - min_sum + 1  # minとmaxの間の数を全て取れる
    ans %= MOD

print(ans)


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

MOD = 10**9 + 7
ans = 0
# 選ぶ個数で場合分け
# 選べる個数はK,K+1,K+2,...,N+1

# 等差数列の和S
# 項数n, 初項a,末項l,公差d
# S=(n/2)*(a+l)
# S=(n/2)*{2a+(n-1)d}

for i in range(K, N + 2):
    min_sum = i * (i - 1) // 2  # 0+1+...(項数=i)
    max_sum = (2 * N - i + 1) * i // 2  # N+(N-1)+...(項数=i)
    ans += max_sum - min_sum + 1  # minとmaxの間の数を全て取れる
    ans %= MOD

print(ans)
# Original solution
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
def ZIP(n): return list(zip(*(MAP() for _ in range(n))))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()

ans = 0
for k in range(K, N+2):
  mi = k*(k-1)//2
  x = N-k
  ma = N*(N+1)//2 - x*(x+1)//2
  ans += ma-mi+1
  ans %= mod

print((ans%mod))

# Optimized solution
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
def ZIP(n): return list(zip(*(MAP() for _ in range(n))))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
ans = 0

for i in range(K, N+2):
  ans += N*(N+1)//2 - (N-i)*(N-i+1)//2 - i*(i-1)//2 +1
  
print((ans%mod))
# Original solution
def solution():
    n, k = list(map(int, input().split()))
    ans = 0
    for i in range(k, n+2):
        smallest = (i-1) * i // 2
        largest = (n-i+1) * i + smallest
        ans += largest - smallest + 1
    ans %= 10 ** 9 + 7
    print(ans)

solution()


# Optimized solution
def solution():
    n, k = list(map(int, input().split()))
    ans = 0
    for i in range(k, n+2):
        smallest = (i-1) * i / 2
        largest = (n-i+1) * i + smallest
        ans += largest - smallest + 1
    ans %= 10 ** 9 + 7
    print((int(ans)))

solution()
# Original solution
MOD = 10**9 + 7


def main():
    N, K = (int(i) for i in input().split())
    ans = 0
    for i in range(K, N+2):
        lower = (i-1)*i//2
        upper = N*(N+1)//2 - (N-i)*(N-i+1)//2
        ans += upper - lower + 1
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()


# Optimized solution
MOD = 10**9 + 7


def main():
    N, K = (int(i) for i in input().split())
    ans = 0
    for i in range(K, N+2):
        # lower = (i-1)*i//2
        # upper = N*i - (i-1)*i//2
        # ans += upper - lower + 1
        ans += i*(N-i+1)+1
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()
# Original solution
mod, ans = 10 ** 9 + 7, 0
N, K = list(map(int, input().split()))
for k in range(K, N + 2):
    ans += (N + 1) * (N + 2) // 2 - (N + 2 - k) * (N + 1 - k) // 2 + 1
    ans -= k * (k + 1) // 2
    ans = ans % mod
print(ans)


# Optimized solution
mod = 10 ** 9 + 7
N, K = list(map(int, input().split()))
ans, R, L = 1, N * (N + 1) // 2, N * (N + 1) // 2
for i in range(N + 1 - K):
    R, L = R - i, L - (N - i)
    ans = (ans + R - L + 1) % mod
print(ans)
# Original solution
N,K=list(map(int,input().split()))
p=10**9 + 7
ans=0
for i in range(K-1,N+1):
  L_min=i*(i+1)//2
  L_max=(N*(N+1)//2)-((N-i-1)*(N-i)//2)
  ans += (L_max-L_min+1)%p
print((ans%p))

# Optimized solution
N,K=list(map(int,input().split()))
p=10**9 + 7
L_min,L_max=0,0
for i in range(K-1,N+1):
  L_min+=i*(i+1)//2 - 1
  L_max+=(N*(N+1)//2)-((N-i-1)*(N-i)//2)
ans = (L_max-L_min)%p
print(ans)
# Original solution
n, k = list(map(int, input().split()))
p = 10**9 + 7
cnt = 0
for i in range(k, n + 2):
    cnt += (i * (n - (i - 1)) + 1) % p
print((cnt % p))

# Optimized solution
n, k = list(map(int, input().split()))
cnt = 0
for i in range(k, n + 2):
    cnt += i * (n - i + 1) + 1
print((cnt % (10**9 + 7)))
# Original solution
n, k = list(map(int, input().split()))
cnt = 0
for i in range(k, n + 2):
    cnt += i * (n - i + 1) + 1
print((cnt % (10**9 + 7)))

# Optimized solution
n, k = list(map(int, input().split()))
print((((n*(n + 1)*(n + 2) - (k - 1)*k*(3*n - 2*k + 4))//6 + n - k + 2) % (10**9 + 7)))
# Original solution
n, k = list(map(int, input().split()))
mod = 10 ** 9 + 7

ans = 0
for t in range(k, n+2):
    mini = t * (t-1) // 2 % mod
    residue = n - t + 1
    maxim = mini + t * residue
    maxim %= mod
    count = maxim - mini + 1
    count %= mod
    ans += count
    ans %= mod

print(ans)


# Optimized solution
n, k = list(map(int, input().split()))
mod = 10 ** 9 + 7

ans = 0
for t in range(k, n+2):
    pattern = t * (n+1-t) + 1 % mod
    ans = (ans + pattern) % mod

print(ans)
# Original solution
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()


# Optimized solution
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()
# Original solution
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()


# Optimized solution
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
    print((ans % mod))


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()
# Original solution
from collections import  deque
import sys
import bisect
import math
import itertools
from queue import deque
from math import gcd

INF = float('inf')
mod = 10**9+7
eps = 10**-7

def inp(): return int(sys.stdin.readline())
 
def inp_list(): return list(map(int, sys.stdin.readline().split()))

def lcm(x, y): return (x * y) // gcd(x, y)

N, K = inp_list()
ans = 0
for k in range(K, N + 2):
    # M => 和の最大値, m => 和の最小値, k について和としてありえるものの個数は M - m + 1
    M = ( N * (N + 1) // 2 - (N - k) * (N + 1 - k) // 2 ) % mod
    m = k * (k - 1) // 2 % mod
    ans += (M - m + 1) % mod

print((ans % mod))


# Optimized solution
from collections import  deque
import sys
import bisect
import math
import itertools
from queue import deque
from math import gcd

INF = float('inf')
mod = 10**9+7
eps = 10**-7

def inp(): return int(sys.stdin.readline())
 
def inp_list(): return list(map(int, sys.stdin.readline().split()))

def lcm(x, y): return (x * y) // gcd(x, y)

N, K = inp_list()
ans = 0
for k in range(K, N + 2):
    # M => 和の最大値, m => 和の最小値, k について和としてありえるものの個数は M - m + 1
    M = ( N * (N + 1) // 2 - (N - k) * (N + 1 - k) // 2 )
    m = k * (k - 1) // 2
    ans += (M - m + 1)

print((ans % mod))
# Original solution
n, k = list(map(int, input().split()))
i = n + 1
mod = 10 ** 9 + 7
ans = 0
while i >= k:
    ans += i * (n - i + 1) + 1
    ans %= mod
    i -= 1
print(ans)

# Optimized solution
n, k = list(map(int, input().split()))
print(((((-2 + k - n)*(-6 + 2* k**2 - n - n**2 - k*(2 + n)))//6)%(10**9+7)))
# Original solution
class Combination:
    def __init__(self, size, mod=10**9 + 7):
        self.size = size + 2
        self.mod = mod
        self.fact = [1, 1] + [0] * size
        self.factInv = [1, 1] + [0] * size
        self.inv = [0, 1] + [0] * size

        for i in range(2, self.size):
            self.fact[i] = self.fact[i - 1] * i % self.mod
            self.inv[i] = -self.inv[self.mod % i] * (self.mod // i) % self.mod
            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % self.mod

    def npr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * self.factInv[n - r] % self.mod

    def ncr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % self.mod) % self.mod

    def nhr(self, n, r):  # 重複組合せ
        return self.ncr(n + r - 1, n - 1)

    def factN(self, n):
        if n < 0:
            return 0
        return self.fact[n]

N, K = list(map(int, input().split()))
MOD = 10**9 + 7
S = N * (N + 1) // 2

ans = 1
for d in range(N + 1):
    if N - d < K:
        break
    mx = S - (d * (d + 1) // 2)
    mi = max(0, (N - d - 1) * ((N - d - 1) + 1) // 2)
    ans += (mx - mi + 1) % MOD
    ans %= MOD
print(ans)

# Optimized solution
N, K = list(map(int, input().split()))
MOD = 10**9 + 7
S = N * (N + 1) // 2

ans = 1
for d in range(N + 1):
    if N - d < K:
        break
    mx = S - (d * (d + 1) // 2)
    mi = max(0, (N - d - 1) * ((N - d - 1) + 1) // 2)
    ans += (mx - mi + 1) % MOD
    ans %= MOD
print(ans)
# Original solution
N, K = list(map(int, input().split()))
MOD = 10**9 + 7
S = N * (N + 1) // 2

ans = 1
for d in range(N + 1):
    if N - d < K:
        break
    mx = S - (d * (d + 1) // 2)
    mi = max(0, (N - d - 1) * ((N - d - 1) + 1) // 2)
    ans += (mx - mi + 1) % MOD
    ans %= MOD
print(ans)

# Optimized solution
N, K = list(map(int, input().split()))
MOD = 10**9 + 7

ans = 0
for k in range(K, N + 2):
    base = k * (k - 1) // 2
    mx = base + k + (N - k) * k
    ans += mx - base + 1
    ans %= MOD

print(ans)
# Original solution
N, K = list(map(int, input().split()))
MOD = 10**9 + 7

ans = 0
for k in range(K, N + 2):
    base = k * (k - 1) // 2
    mx = base + k + (N - k) * k
    ans += mx - base + 1
    ans %= MOD

print(ans)


# Optimized solution
N, K = list(map(int, input().split()))
MOD = 10**9 + 7

ans = 0
for k in range(K, N + 2):
    S = k * (k - 1) // 2
    mx = N * k - S
    mi = S
    ans += mx - mi + 1
    ans %= MOD
print(ans)
# Original solution
n, k = list(map(int, input().split()))
ans = 0
mod = 10 **9 + 7
for i in range(k, n+2):
    # i個(k<= i <= n+1)を選ぶとき
    # i * 10^100 + (1+2+・・・+(i-1)) 〜 i * 10^100 + (n + (n-1) + ・・・ + (n-(i-1) ) )
    # の間の値をとりうるので
    # i*(n + n-(i-1))//2 - (i-1)*i//2 + 1 = i * (n-i+1) + 1
    ans += i * (n - i + 1) + 1
print((ans % mod))

# Optimized solution
n,k=list(map(int,input().split()))
print(((((k-n-2)*(2*k**2-k*(n+2)-n**2-n-6)))//6%(10**9+7)))
# Original solution
n, k = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0
for i in range(k, n+2):
    ans += i*(n-i+1) + 1
    ans %= mod
print(ans)

# Optimized solution
n, k = list(map(int, input().split()))
print(((n-k+2)*(n**2-2*k**2+k*(n+2)+n+6)//6 % (10**9+7)))
# Original solution
N, K = list(map(int, input().split()))
ans = 0
for i in range(K, N+2):
    ans += i*(N-i+1)+1

print((ans%1000000007))

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

print((int(((N*(N+1)*(N+2) - K*(K-1)*(3*N-2*K+4))/6 + N - K + 2)%1000000007)))
# Original solution
a,b=(int(x) for x in input().split())
z=0
for i in range(b,a+2):
  z=(z+(a-i+1)*i+1)%int(1e9+7)
print(z)

# Optimized solution
a,b=(int(x) for x in input().split())
z=0
for i in range(b,a+2):z=(z+(a-i+1)*i+1)%(10**9+7)
print(z)
# Original solution
a,b=(int(x) for x in input().split())
z=0
while b<=a+1:z=(z+(a-b+1)*b+1)%int(1e9+7);b+=1
print(z)

# Optimized solution
a,b=(int(x)for x in input().split())
z=0
while b<=a+1:z=(z+(a-b+1)*b+1)%(10**9+7);b+=1
print(z)
# Original solution
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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

    res = 0
    for i in range(k, n + 2):
        mi = (i - 1) * i // 2
        ma = n * (n + 1) // 2 - (n - i) * (n - i + 1) // 2
        res += ma - mi + 1
        res %= mod

    print(res)


if __name__ == '__main__':
    resolve()


# Optimized solution
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


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

    res = 0
    for i in range(k, n + 2):
        mi = (i - 1) * i // 2
        ma = (n + (n - i + 1)) * i // 2
        res += ma - mi + 1
        res %= mod
    print(res)


if __name__ == '__main__':
    resolve()
# Original solution
'''ika tako
選ぶ個数を固定して、それ毎に結果を足し合わせればよい。
k  個の数を選ぶとき、各項に含まれる  10^100  は除いて考えても
和の個数を求める上では問題ない。
最小値は小さい方から  k  個を足し合わせた数0+1+2+…+(k-1)
初項  0 、末項  k−1 、長さ  k  の等差数列の総和なので  
k(k−1)/2 
最大値は大きい方から  k  個を足し合わせた数(N-k+1)+…+(N-1)+N
初項  N−k+1 、末項N 、長さk  の等差数列の総和なので  
k(2N−k+1)/2 
数字は1刻みで、特に選び方に制約も無いので、最小値～最大値の間の整数は全て作れる。
'''
# 累積和解法
from itertools import accumulate
 
n, k = list(map(int, input().split()))
MOD = 10 ** 9 + 7
f_acc = [0] + list(accumulate(list(range(n + 1))))
b_acc = [0] + list(accumulate(reversed(list(range(n + 1)))))
ans = 0
for i in range(k, n + 2):
    min_ = f_acc[i]
    max_ = b_acc[i]
    ans = (ans + max_ - min_ + 1) % MOD
print(ans)

# Optimized solution
N, K = list(map(int,input().split()))
ans = 0
MOD = 10**9 + 7
for i in range(K,N+2):
    x = (N+1-i) * i + 1
    ans += x
    ans %= MOD
print (ans)
# Original solution
import math
import queue
 
def readInt():
	return int(eval(input()))
 
def readInts():
	return list(map(int, input().split()))
 
def readChars():
	return input().split()

x = readInts()
n = x[0]
k = x[1]

def ts(l):
	return int((l*(l-1))/2)

def ts2(l):
	return int(l*(n+n-(l-1))/2)

s = 0

for i in range(k,n+2):
	s += ts2(i)+1-ts(i)

print((s%(1000000007)))

# Optimized solution
x=list(map(int,input().split()))
n,k=x
s=0
for i in range(k,n+2):
	s+=int(i*(n+n-(i-1))/2)+1-int((i*(i-1))/2)
print((s%(1000000007)))
# Original solution
n,k=list(map(int,input().split()))
s=0
for i in range(k,n+2):
	s+=int(i*(n+n-(i-1))/2)+1-int((i*(i-1))/2)
print((s%(1000000007)))

# Optimized solution
n,k=list(map(int,input().split()))
s=0
for i in range(k,n+2):
	s+=i*(n+n-(i-1))//2+1-(i*(i-1))//2
print((s%(1000000007)))
# Original solution
n,k=list(map(int,input().split()))
s=0
for i in range(k,n+2):
	s+=i*(n+n-(i-1))//2+1-(i*(i-1))//2
print((s%(1000000007)))

# Optimized solution
n,k=list(map(int,input().split()))
s=0
for i in range(k,n+2):
	s+=i*(2*n-i+1)//2+1-(i*(i-1))//2
print((s%(1000000007)))
# Original solution
n,k=list(map(int,input().split()))
s=0
for i in range(k,n+2):
	s+=i*(2*n-i+1)//2+1-(i*(i-1))//2
print((s%(1000000007)))

# Optimized solution
n,k=list(map(int,input().split()))
s=0
for i in range(k,n+2):
	s+=i*(n-i+1)+1
print((s%(1000000007)))
# Original solution
n,k=list(map(int,input().split()))
s=0
for i in range(k,n+2):
	s+=i*(n-i+1)+1
print((s%(1000000007)))

# Optimized solution
n,k=list(map(int,input().split()))
s=0
for i in range(k,n+2):
	s+=i*(n-i+1)+1
print((s%(10**9+7)))
# Original solution
N, K = list(map(int, input().split()))
ans = 0
mod = 10**9+7
for i in range(K, N+2):
    _min = (i+1)*i//2
    _max = ((N+1) + (N+1-i+1)) * i // 2
    ans += (_max - _min + 1) % mod
    ans %= mod
print(ans)

# Optimized solution
N, K = list(map(int, input().split()))
M = 10**9 + 7
ans = 0
for i in range(K, N+2):
    _min = (i-1)*i//2 
    _max =  (N + N-i+1) * i //2 
    ans += (_max - _min + 1) 
print((ans % M))
# Original solution
N, K = list(map(int, input().split()))
M = 10**9 + 7
ans = 0
for i in range(K, N+2):
    _min = (i-1)*i//2 
    _max =  (N + N-i+1) * i //2 
    ans += (_max - _min + 1) 
print((ans % M))

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

ans = 0
mod = 10**9+7
for i in range(K, N+2):
    min = i*(i-1)/2
    max = (2*N-i+1)*i/2
    ans += max - min + 1
print((int(ans%mod)))
# Original solution
n, k = list(map(int, input().split()))

MOD = 10**9 + 7
ans = 0

for c in range(k, n + 2):
  m = c * (c - 1) // 2
  M = c * (2 * (n + 1) - c - 1) // 2
  ans += M - m + 1
  ans %= MOD

print(ans)


# Optimized solution
n, k = list(map(int, input().split()))
MOD = 10**9 + 7
print(((-2 + k - n) * (-6 - 2 * k + 2 * k**2 - n - k * n - n**2) // 6 % MOD))
# Original solution
n, k = list(map(int, input().split()))
MOD = 10**9 + 7
print(((-2 + k - n) * (-6 - 2 * k + 2 * k**2 - n - k * n - n**2) // 6 % MOD))

# Optimized solution
n,k=list(map(int,input().split()))
print(((-2+k-n)*(-6-2*k+2*k**2-n-k*n-n**2)//6%(10**9+7)))