CodeEff/ECCO huggingface dataset:
# Original solution
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(eval(input()))

def MI(): return list(map(int, input().split()))
def MI1(): return list(map(int1, input().split()))

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')


def solve():
    n, k = MI()
    B = [i for i in range(n+1)]
    # print(B)
    mod = 1000_000_007
    def f(l, r):
        return (r + l) * (r - l + 1) // 2

    ans = 0
    for i in range(k, n+2):
        # print(B[0], B[i-1], B[n-i+1], B[-1])
        _min = f(B[0], B[i-1])
        _max = f(B[n-i+1], B[-1])
        # print('  ', _min, _max, _max - _min + 1)
        ans = (ans + _max - _min + 1) % mod
    print(ans)


if __name__ == '__main__':
    solve()


# Optimized solution
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(eval(input()))
def MI(): return list(map(int, input().split()))
def MI1(): return list(map(int1, input().split()))
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(eval(input()))
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print((k.join(list(map(str, lst)))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right
def f(l, r, kousa=1):
    n = (r - l) // kousa
    return (r + l) * (n + 1) // 2

def solve():
    N, K = MI()
    ans = 0
    MOD = 1000000007
    for i in range(K, N+2):
        mn = f(0, i-1)
        mx = f(N-i+1, N)
        ans = ans + mx - mn + 1
    print((ans % MOD))

if __name__ == '__main__':
    solve()
# Original solution
# -*- coding: utf-8 -*-

import sys
from itertools import accumulate

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

class ModTools:
    """ 階乗たくさん使う時用のテーブル準備 """

    def __init__(self, MAX, MOD):
        """ MAX：階乗に使う数値の最大以上まで作る """
        
        MAX += 1
        self.MAX = MAX
        self.MOD = MOD
        factorial = [1] * MAX
        factorial[0] = factorial[1] = 1
        for i in range(2, MAX):
            factorial[i] = factorial[i-1] * i % MOD
        inverse = [1] * MAX
        inverse[MAX-1] = pow(factorial[MAX-1], MOD-2, MOD)
        for i in range(MAX-2, -1, -1):
            inverse[i] = inverse[i+1] * (i+1) % MOD
        self.fact = factorial
        self.inv = inverse
    
    def nCr(self, n, r):
        """ 組み合わせの数 (必要な階乗と逆元のテーブルを事前に作っておく) """

        if n < r: return 0
        r = min(r, n-r)
        numerator = self.fact[n]
        denominator = self.inv[r] * self.inv[n-r] % self.MOD
        return numerator * denominator % self.MOD

    def div(self, x, y):
        """ MOD除算 """

        return x * pow(y, self.MOD-2, self.MOD) % self.MOD

N, K = MAP()

acc = list(range(N+2))
acc = list(accumulate(acc))

mt = ModTools(N+1, MOD)
ans = 0
for i in range(K, N+2):
    cnt = (acc[N+1] - acc[N+1-i]) - acc[i] + 1
    ans += cnt
    ans %= MOD
print(ans)


# Optimized solution
# -*- coding: utf-8 -*-

import sys
from itertools import accumulate

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, K = MAP()

acc = list(range(N+2))
acc = list(accumulate(acc))

ans = 0
for i in range(K, N+2):
    ans += (acc[N+1] - acc[N+1-i]) - acc[i] + 1
    ans %= MOD
print(ans)
# Original solution
mod = 10**9 + 7

n,k = list(map(int,input().split()))
tot = []
cur = 0
for i in range(n+1):
    cur += i
    tot.append(cur)

cnt = 0
for i in range(k, n+2):
    if n > i:
        max_ = tot[n] - tot[n - i]
    else:
        max_ = tot[n]
    min_ = tot[i - 1]
    cnt += max_ - min_ + 1
    cnt %= mod
print(cnt)

# Optimized solution
# しゃくとり

mod = 10**9 + 7

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

cnt = 0
sum_ = sum(range(n + 1))
#print("sum", sum_)
#print(list(range(n + 1)))
max_ = sum(range(n - k + 1, n + 1))
min_ = sum(range(k))
for i in range(k, n+2):
    #print(max_, min_, cnt)
    cnt += max_ - min_ + 1
    cnt %= mod
    #print(cnt)
    
    if n > i + 1:
        max_ +=  n - i
    else:
        max_ = sum_
    min_ += i
print(cnt)
# Original solution
N,K = list(map(int,input().split()))
 
s = 0
 
for i in range(K,N+2):
  s += i*N +1 - i*(i -1)

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

# Optimized solution
N,K = list(map(int,input().split()))
 
s = int( (N*(N+1)*(N+2))/6 - (K*(K-1)*(3*N-2*K+4))/6 + N-K+2 )
 
print((s%(10**9 + 7)))
# Original solution
def rui_sum(n,k):
    k_lsum = (k-1)*k//2
    k_usum = k*n - (k-1)*k//2    
    return k_usum - k_lsum + 1

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

cnt = []

for i in range(k,n+2):
    cnt.append(rui_sum(n,i))
    
print((sum(cnt)%(10**9+7)))

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

cnt = []

for i in range(k,n+2):
    cnt.append(i*n -(i-1)*i +1)
    
print((sum(cnt)%(10**9+7)))
# Original solution
import sys
mod = 7 + 10 ** 9

def solve():
    input = sys.stdin.readline
    N, K = list(map(int, input().split()))
    ans = 0
    for k in range(K, N + 2):
        minSum = (0 + k - 1) * k // 2
        maxSum = (N - k + 1 + N) * k // 2
        ans += (maxSum - minSum + 1) % mod
        ans %= mod
    print(ans)
    


    return 0

if __name__ == "__main__":
    solve()

# Optimized solution
import sys
mod = 7 + 10 ** 9

def solve():
    input = sys.stdin.readline
    N, K = list(map(int, input().split()))
    ans = 0
    for k in range(K, N + 2):
        minS = (k - 1) * k // 2
        maxS = (N - k + 1 + N) * k // 2
        ans += (maxS - minS + 1)
        ans %= mod

    print(ans) 

    return 0

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

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

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

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


# Optimized solution
N, K = list(map(int,input().split()))
MOD = 10**9 + 7
ans = 0
for i in range(K,N+2):
    # iこ えらぶ
    ans += (N+1)*N//2-(N-i)*(N-i+1)//2-i*(i-1)//2+1
    ans %= MOD
print(ans)
# Original solution
N, K = list(map(int,input().split()))
MOD = 10**9 + 7
ans = 0
for i in range(K,N+2):
    # iこ えらぶ
    ans += (N+1)*N//2-(N-i)*(N-i+1)//2-i*(i-1)//2+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):
    m = (k*(k-1))//2
    M = (k*(N+N-k+1))//2
    ans += M-m+1

print((ans%MOD))
# Original solution
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
import sys,bisect,string,math,time,functools,random
def Golf():*a,=map(int,open(0))
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[];g=[[] for i in range(n)]
    for i in range(E):
        inp=LI();org_inp.append(inp)
        if index==0:inp[0]-=1;inp[1]-=1
        if len(inp)==2:
            a,b=inp;g[a].append(b)
            if not Directed:g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp;aa=(inp[0],inp[2]);bb=(inp[1],inp[2]);g[a].append(bb)
            if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[1]*(w+2);found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)];rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)

YN=['YES','NO'];Yn=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()

class Comb:
    def __init__(self,n,mo=10**9+7):
        self.fac=[0]*(n+1)
        self.inv=[1]*(n+1)
        self.fac[0]=1
        self.fact(n)
        for i in range(1,n+1):
            self.fac[i]=i*self.fac[i-1]%mo
            self.inv[n]*=i
            self.inv[n]%=mo
        self.inv[n]=pow(self.inv[n],mo-2,mo)
        for i in range(1,n):
            self.inv[n-i]=self.inv[n-i+1]*(n-i+1)%mo
        return
    
    def fact(self,n):
        return self.fac[n]
        
    def invf(self,n):
        return self.inv[n]

    def comb(self,x,y):
        if y<0 or y>x:
            return 0
        return self.fac[x]*self.inv[x-y]*self.inv[y]%mo

show_flg=False
show_flg=True

ans=0

n,k=LI()

for i in range(k,n+1+1):
    #r=(n+n-k+1)*k//2-(k-1)*k//2+1
    r=(n+n-i+1)*i//2-(i-1)*i//2+1
    r%=mo
    ans+=r
    #show(i,r)


print(ans%mo)






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

N,K = list(map(int,input().split()))
s = 0
for k in range(K, N+2):
	s = (s + N*k - k*k + k + 1) % MOD
print(s)

# Optimized solution
N,K = list(map(int,input().split()))
print(((((N+1)*(N+2-K)*(K+N+1))//2 - ((N+1)*(N+2)*(2*N+3))//6 + (K*(K-1)*(2*K-1))//6 + N + 2 - K) % (10**9 + 7)))
# Original solution
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()


# Optimized solution
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()
# Original solution
n,k=list(map(int,input().split()))
ans=0
for i in range(k,n+2):
    a=0.5*i*(i-1)
    b=0.5*n*(n+1)-0.5*(n-i)*(n-i+1)
    ans+=int(b-a+1)


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

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

def calc(a):
    smallest = a * (a-1) // 2
    largest = smallest + a * (n-a+1)
    return largest - smallest + 1


ans = 0
for a in range(k, n+2):
    ans += calc(a)
    ans %= MOD

print(ans)
# Original solution
N,K=list(map(int,input().split()))
ans=0
kari=[i for i in range(N+1)]
for i in range(K,N+2):
    saidai=(N+N-i+1)*i//2
    saisyou=(i-1)*i//2
    ans+=saidai-saisyou+1

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

# Optimized solution
N,K=list(map(int,input().split()))
ans=0
for i in range(K,N+2):
    saidai=(N+N-i+1)*i//2
    saisyou=(i-1)*i//2
    ans+=saidai-saisyou+1

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


# Optimized solution
N, K = list(map(int, input().split()))
MOD = 10**9+7
f = lambda x:x*(x+1)//2
ans = sum(f(N)-f(N-i)-f(i-1)+1 for i in range(K, N+2))%MOD
print(ans)
# Original solution
N, K = list(map(int, input().split()))
MOD = 10**9+7
f = lambda x:x*(x+1)//2
ans = sum(f(N)-f(N-i)-f(i-1)+1 for i in range(K, N+2))%MOD
print(ans)


# Optimized solution
N, K = list(map(int, input().split()))
f = lambda x:x*(x+1)//2
print((sum(f(N)-f(N-i)-f(i-1)+1 for i in range(K, N+2))%(10**9+7)))
# Original solution
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

mod = 10**9+7

def modinv(a, mod):
    return pow_mod(a, mod-2, mod)

def pow_mod(a, b, mod):
    x = 1
    while b > 0:
        if b & 1:
            x = (x*a)%mod
        a = (a**2)%mod
        b //= 2
 
    return x

def comb(n,r,mod):
    combsum=1
    for i in range(n-r+1,n+1):
        combsum = (combsum * i)%mod
    for i in range(1,r+1):
        combsum = (combsum * inv[i])%mod
    return combsum

inv=[modinv(i,mod) for i in range(0,2*10**5)]

def yn(b):
    print(("Yes" if b==1 else "No"))
    return

def resolve():
    readline=sys.stdin.readline

    n,k=list(map(int, readline().rstrip().split()))

    a=0
    z=0
    ans=0
    n+=1
    for i in range(1,n+1):
        a+=i
        z+=(n-i+1)
        cnt=z-a+1
        if i>=k:
            ans+=cnt
            ans%=mod
    print(ans)
    #arr=list(map(int, readline().rstrip().split()))
    #n=int(readline())
    #ss=readline().rstrip()
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

# Optimized solution
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print(("Yes" if b==1 else "No"))
    return

def resolve():
    readline=sys.stdin.readline

    n,k=list(map(int, readline().rstrip().split()))

    mod = 10**9+7
    a=0
    z=0
    ans=0
    n+=1
    for i in range(1,n+1):
        a+=i
        z+=(n-i+1)
        cnt=z-a+1
        if i>=k:
            ans=(ans+cnt)%mod
    print(ans)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------
# Original solution
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

mod = 10**9+7

def modinv(a, mod):
    return pow_mod(a, mod-2, mod)

def pow_mod(a, b, mod):
    x = 1
    while b > 0:
        if b & 1:
            x = (x*a)%mod
        a = (a**2)%mod
        b //= 2
 
    return x

def comb(n,r,mod):
    combsum=1
    for i in range(n-r+1,n+1):
        combsum = (combsum * i)%mod
    for i in range(1,r+1):
        combsum = (combsum * inv[i])%mod
    return combsum

inv=[modinv(i,mod) for i in range(0,2*10**5)]

def yn(b):
    print(("Yes" if b==1 else "No"))
    return

def resolve():
    readline=sys.stdin.readline

    n,k=list(map(int, readline().rstrip().split()))

    a=0
    z=0
    ans=0
    n+=1
    for i in range(1,n+1):
        a+=i
        z+=(n-i+1)
        cnt=z-a+1
        if i>=k:
            ans+=cnt
            ans%=mod
    print(ans)
    #arr=list(map(int, readline().rstrip().split()))
    #n=int(readline())
    #ss=readline().rstrip()
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------


# Optimized solution
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print(("Yes" if b==1 else "No"))
    return

def resolve():
    readline=sys.stdin.readline

    n,k=list(map(int, readline().rstrip().split()))

    mod = 10**9+7
    a=0
    z=0
    ans=0
    n+=1
    for i in range(1,n+1):
        a+=i
        z+=(n-i+1)
        cnt=z-a+1
        if i>=k:
            ans+=cnt
            ans%=mod
    print(ans)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

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


# Optimized solution
n,k=list(map(int,input().split()))
mod=pow(10,9)+7
ans=0
for i in range(k,n+2):
    ans+=(i*(n+n-i+1))//2-(i*(i-1))//2+1
    ans%=mod
print(ans)
# Original solution
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,k = list(map(int,input().split()))
class InverseTable:
    __slots__ = ['In', 'fac', 'Ifac']

    def __init__(self, mod, maxnum):
        self.In = [0, 1]; self.fac = [1, 1]; self.Ifac = [1, 1]
        for i in range( 2, maxnum + 1 ):
            self.In.append( ( -self.In[mod % i] * (mod//i) ) % mod )
            self.fac.append( ( self.fac[-1] * i ) % mod )
            self.Ifac.append( (self.Ifac[-1] * self.In[-1]) % mod )
        
    def cmb(self, n, r):
        if ( r<0 or r>n ): return 0
        r = min(r, n-r)
        return self.fac[n] * self.Ifac[r] * self.Ifac[n-r] % mod
    
    def per(self, n, r):
        if ( r<0 or r>n ): return 0
        return self.fac[n] * self.Ifac[n-r] % mod

invt = InverseTable(mod, 10**6)
# maxnum=10**6だとテーブル生成に200ms程かかるので（Pythonだと1000msほど）
# 最大生成領域は問題ごとに要検討
teisu = n*(n+1)//2
for i in range(k,n+2):
  ans += teisu-(n-i)*(n-i+1)//2-(i-1)*(i)//2 + 1
  ans%=mod
  # print(i,ans)
print((ans%mod))

  

# Optimized solution
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

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

for i in range(k, n+2):
	minunchi = (i*(i-1))//2
	maxunchi = (n*(n+1))//2 - ((n+1-i)*(n-i))//2
	sum += maxunchi - minunchi + 1

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

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

DIVIDER = 1000000007

tab_sum = [0]
sum_tmp = 0
for i in range(N + 1):
    sum_tmp = (sum_tmp + i) % DIVIDER
    tab_sum.append(sum_tmp)

ans = 0
for cnt in range(K, N + 2):
    val_min = (tab_sum[cnt] - tab_sum[0]) % DIVIDER
    val_max = (tab_sum[-1] - tab_sum[-1 - cnt]) % DIVIDER
    #
    ans = (ans + (val_max - val_min + 1)) % DIVIDER

print(ans)

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

tab_sum = [0]
sum_tmp = 0
for i in range(N + 1):
    sum_tmp += i
    tab_sum.append(sum_tmp)

ans = 0
DIVIDER = 1000000007
for cnt in range(K, (N + 1) + 1):
    sum_min = tab_sum[cnt] - tab_sum[0]
    sum_max = tab_sum[-1] - tab_sum[-1 - cnt]
    #
    ans = (ans + (sum_max - sum_min + 1)) % DIVIDER

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

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

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

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

ans = 1
for k in range(K, N + 1):
    sum_min = k * (k - 1) // 2
    sum_max = k * N - k * (k - 1) // 2
    ans += sum_max - sum_min + 1
    
print((ans % (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):
    ans += int(n*(n+1)/2 - (n-i)*(n-i+1)/2 - (i-1)*i/2 + 1)
print((ans % mod))

'''
n, k = map(int, input().split())
ans = 0
for i in range(k, n+2):
    a = 0.5*i*(i-1)
    b = 0.5*n*(n+1)-0.5*(n-i)*(n-i+1)
    ans += int(b-a+1)

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


# Optimized solution
n, k = list(map(int, input().split()))
ans = 0
for i in range(k, n+2):
    ma = (n+n-i+1)*i//2
    mi = (i-1)*i//2
    # print(ma, mi)
    add = ma-mi+1
    ans += add

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

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

ans = 0
for i in range(K, N + 2):
    max_num = i * (N + N + 1 - i) // 2
    min_num = i * (0 + i - 1) // 2
    ans += max_num - min_num + 1

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

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