Problem:
 Score : 400 points    Problem Statement We have N+1 integers: 10^{100} , 10^{100}+1 , ..., 10^{100}+N .  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7) .      Constraints  1 \leq N \leq 2\times 10^5  1 \leq K \leq N+1  All values in input are integers.         Input Input is given from Standard Input in the following format:  N  K       Output Print the number of possible values of the sum, modulo (10^9+7) .        Sample Input 1 3 2      Sample Output 1 10  The sum can take 10 values, as follows:   (10^{100})+(10^{100}+1)=2\times 10^{100}+1  (10^{100})+(10^{100}+2)=2\times 10^{100}+2  (10^{100})+(10^{100}+3)=(10^{100}+1)+(10^{100}+2)=2\times 10^{100}+3  (10^{100}+1)+(10^{100}+3)=2\times 10^{100}+4  (10^{100}+2)+(10^{100}+3)=2\times 10^{100}+5  (10^{100})+(10^{100}+1)+(10^{100}+2)=3\times 10^{100}+3  (10^{100})+(10^{100}+1)+(10^{100}+3)=3\times 10^{100}+4  (10^{100})+(10^{100}+2)+(10^{100}+3)=3\times 10^{100}+5  (10^{100}+1)+(10^{100}+2)+(10^{100}+3)=3\times 10^{100}+6  (10^{100})+(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=4\times 10^{100}+6        Sample Input 2 200000 200001      Sample Output 2 1  We must choose all of the integers, so the sum can take just 1 value.       Sample Input 3 141421 35623      Sample Output 3 220280457

Solution (Python):
def touSum(a,l):
    return int(((l-a+1)*(a+l))/2)

N,K = map(int,input().split())
maxSum = touSum(1,N)

con = 0
for i in range(K,N+1+1):
    
    if touSum(1,i-1)>maxSum:
        print(con)
        break
    else:
        con += touSum((1+N)-i,N) -touSum(1,i-1)+1
print(con%(10**9+7))

Solution (Python):
N,K = map(int,input().split())


wa = 0

souwa = 0


dprime = 10**9 + 7


for k in range(1,N+2):


    
    
    if k >= K:
        
        mx = N*k-wa

        souwa += (mx - wa + 1) % dprime

    wa += k
        
print(souwa%dprime)

Solution (Python):
N,K = map(int,input().split())
l=list(range(K,N+2))
sum =0
for i in l:
    m=(i-1)*i/2
    p=i*N-2*m+1
    sum+=p

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

Solution (Python):
N,K=map(int, input().split())

a=0
start=0
end=0

for i in range(1,N+2):
    start=start+i-1
    end=end+N-i+1

    if i >= K:
        a = (a + (end - start)+1) % (10**9+7)

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

Solution (Python):
NK = input().split()
N = int(NK[0])
K = int(NK[1])
x = 0
for i in range(N-K+2):
    a = N+1
    b = i+K
    x += (a-b)*b+1
print(x%1000000007)

Solution (Python):
n,k=map(int,input().split())
mod=10**9+7
L=[i for i in range(n+1)]
RS=[0]*(n+1)
for i in range(n):
    RS[i+1]=RS[i]+L[i+1]
r=0
for i in range(k,n+1):
    r+=RS[n]-RS[n-i]-RS[i-1]+1
print((r+1)%mod)

Solution (Python):
def rangesum(a, b=0):
    return (abs(a-b)+1) * (a+b) // 2

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

mod = 10**9+7
res = 1
for i in range(k, n+1):
    res += rangesum(n-i+1, n) - rangesum(i-1) + 1
    res %= mod

print(res)

Solution (Python):


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(input())
def MAP(): return 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)

Solution (Python):

mod = 10 ** 9 + 7

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

rst = 0
for i in range(k, n+2):
    _min = (i * (i - 1)) // 2
    _max = (i * ((n-i+1) + (n))) // 2
    rst += _max - _min + 1
    rst %= mod

print(rst)

Solution (Python):
n,k=map(int,input().split())
count=0
for i in range(k,n+2):
    count+=i*(n-i+1)+1
print(count%(10**9+7))

Solution (Python):
INT_MAX=10**18+7
MOD=10**9+7
def INPUT():return list(int(i) for i in input().split())
def LIST_1D_ARRAY(n):return [0 for _ in range(n)]
def LIST_2D_ARRAY(m,n):return [[0 for _ in range(n)]for _ in range(m)]

n,K=INPUT()
ways=0
for k in range(K,n+2):
        ways+=(k*(2*n-k+1))//2 - ((k)*(k-1))//2 +1
print(ways%MOD)

Solution (Python):

import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline
from collections import defaultdict
from heapq import heappop, heappush

from decimal import *

























def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

inf = float('inf')
mod = 1000000007




def main():
	N,K = inputMap()
	N += 1

	if N == K or K == 0:
		print(1)
		sys.exit()

	ans = 0
	tmp = [tmp for tmp in range(0,N)]
	sample1 = []
	tt = 0
	for i in tmp:
		tt += i
		sample1.append(tt)

	sample2 = []
	tmp = tmp[::-1]
	tt = 0
	for i in tmp:
		tt += i
		sample2.append(tt)
	

	for i in range(K,N+1):
		tmp_i = i-1
		min_int = sample1[tmp_i]
		max_int = sample2[tmp_i]

		

		ans += max_int-min_int+1
		ans = ans % mod

	print(ans)





def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res


def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y



def H(n, r, mod=10**9+7):
	
	
    return combination(n+r-1, r, mod)

class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        
        
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

if __name__ == "__main__":
	main()

Solution (Python):
N,K = map(int,input().split())
ans = 0
temp_max = 0
temp_min = 0
for i in range(1,N+2):
  temp_max += N-i+1
  temp_min += i-1
  if i  >= K:
    ans += (temp_max - temp_min + 1)
print(ans%(10**9+7))

Solution (Python):
n,k = map(int,input().split())
ans = 0

for i in range(k,n+2):
    tmpans = 0
    s1 = (0+i-1)*i//2
    s2 = (n-i+1 + n)*i//2
    tmpans = s2-s1+1
    ans = (ans+tmpans)%(10**9+7)
print(max(1,ans%(10**9+7)))

Solution (Python):
N,K=map(int, input().split())
ans=0
mod=10**9+7
for i in range(K,N+2):
  if i==K:
    MIN=sum(list(range(0,K)))
    MAX=sum(list(range(N,N-K,-1)))
  else:
    MIN+=i-1
    MAX+=N+1-i
  
  ans+=(MAX-MIN+1)%mod
  ans%=mod
print(ans)

Solution (Python):
N,K = map(int,input().split())
M = 10**9+7
ans = 0
for i in range(K,N+1):
    if i == K:t = sum(range(N-i+1,N+1))-sum(range(0,i))
    else: t+=N-(i-1)-(i-1)
    
    t%=M
    ans +=t+1
    ans%=M
    


print(ans+1)

Solution (Python):
'''import os
import sys
from io import BytesIO, IOBase
 
BUFSIZE = 8192
 
 
class FastIO(IOBase):
    newlines = 0
 
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
 
 
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")'''

n,k=map(int,input().split())
l=[]
c=0
for i in range(n+1):
    c+=i
    l.append(c)
ans=0
for i in range(k,n+1):
    ans+=l[-1]-l[n-i]-l[i-1]+1
    ans=ans%1000000007
ans+=1
print(ans)

Solution (Python):
N,K = map(int,input().split())
lst = list(range(0,N+1))
m = 10**9 + 7
cnt = 0
start = sum(lst[:K])
end = sum(lst[-K:])
cnt += end - start + 1
for i in range(K+1,N+2):
    start += lst[i-1] 
    end += lst[-i]
    cnt += end - start + 1
print(cnt % m)

Solution (Python):

N, K = map(int, input().split())
count=0
for i in range(K,N+2):
    min_a=(i-1)*i/2
    max_a=(N+(N-i+1))*i/2
    count+=max_a-min_a+1
print(int(count)%(10**9+7))

Solution (Python):
N,K = map(int, input().split())

i = K
S = 0
while i < N+1:
    S = S + (N+1-i)*i+1
    i = i + 1
S = S + 1

print(int(S%1000000007))

Solution (Python):
N, K = [int(n) for n in input().split()]

a = N - K + 2 + (N + 1)*(N-K+2)*(K+N+1) // 2 - ((N + 1) * (N + 2) * (2 * N + 3) - K * (K - 1) * (2 * K - 1)) // 6

print(a % 1000000007)

Solution (Python):
N,K=map(int,input().split())
ans=0
for i in range(K,N+2):
    kos=((2*N-i+1)*i)//2-((i-1)*i)//2+1
    ans=(ans+kos)%(10**9+7)
print(ans)

Solution (Python):
N, K = map(int, input().split())

MOD = 10**9 + 7
def f(t):
  return (N-t+1)*t+1

ans = 0
for i in range(K, N+2):
  ans += f(i)
  ans %= MOD
print(ans)

Solution (Python):
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)

Solution (Python):
MOD = int(1e9)+7
def main():
    n, k = map(int, input().split())
    n += 1
    a = [int(i) for i in range(n)]
    s = [0]
    for i in range(n):
        s.append(s[i]+a[i])

    ans = 0 
    for i in range(k, n+1):
        ans += s[n]-s[n-i]-s[i]+1
        ans %= MOD
    print(ans%MOD)
main()

Solution (Python):

"""
Created on Sun Apr 19 21:27:49 2020

@author: arute
"""


from sys import stdin

import time
import numpy as np
import math



def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))




temp = stdin.readline().split()
N = int(temp[0])
M = int(temp[1])


probs = np.zeros(1).astype("int64")

for i,m in enumerate(range(M,N+2)):
    
    if i == 0:
        small = np.sum(np.arange(m))
        
        large = np.sum(np.arange(N+1-m,N+1))
    else:
        small = (small+m-1).astype("int64")
        large = (large + (N+1-m)).astype("int64")
    probs = probs + (large - small + 1)

print(int(probs%(1e9+7)))

Solution (Python):
n,k= map(int,input().split())
ans = 0
for i in range(n-k+1):
     ans += (((n-(2*i))*(n-k+1-i))%(10**9+7))

print((ans+n-k+2)%(10**9+7))

Solution (Python):
n, k = map(int, input().split())
cnt = 1
head = 0
head_total = 0
tail = n
tail_total = 0
mod = 10**9+7
for i in range(n + 1):
    if i >= k:
        cnt += tail_total - head_total + 1
        cnt %= mod
    head_total += head
    tail_total += tail
    head += 1
    tail -= 1
print(cnt % mod)

Solution (Python):
import math
n,k = map(int,input().split())
ans = 0
def count(i):
    min_a = ((i - 1) * i )// 2
    max_a = ((n - i + 1 + n) * i) // 2
    return max_a - min_a + 1

for i in range(k,n + 2):
    ans += count(i)
print(ans % (10 ** 9 + 7))

Solution (Python):
n,k = map(int,input().split())
ans = 0

for i in range(k,n+2):
    tmpans = 0
    s1 = (0+i-1)*i//2
    s2 = (n-i+1 + n)*i//2
    tmpans = s2-s1+1
    ans += tmpans
print(max(1,ans%(10**9+7)))

Solution (Python):
N,K=input().split()
MOD = 1000000007
mmax = 0
mmin = 0
result = 0
for i in range(int(N)+1):
    mmin = mmin + i
    mmax = mmax + int(N) - i
    if i >= int(K) - 1:
        result = result + mmax - mmin + 1
print(result%MOD)

Solution (Python):
N , K = map(int,input().split())

N = N + 1
S = 0
for i in range(K , N + 1) :
  t = (i * (N - i) + 1) % (10**9+7)
  S += t
print(S % (10**9+7))

Solution (Python):
mod = 10**9 + 7
n, k = map(int, input().split())

f = {0:0}
s = {0:0}

for i in range(1, 10**6):
    f[i] = (f[i-1] + i) % mod
    s[i] = (s[i-1] + pow(i, 2, mod)) % mod


def solve(n, k):
    ans = (n+1) * ((f[n+1]-f[k-1])%mod) % mod
    sub = (s[n+1] - s[k-1]) % mod
    ans = (ans - sub) % mod
    ans = (ans + n-k+2) % mod

    return ans

ans = solve(n, k)
print(ans)

Solution (Python):
from operator import mul
from functools import reduce


n, k = map(int, input().split())
res = 0
for i in range(k, n+2):
    over = (2*n-i+1)*i/2
    under = (i-1)*i/2
    res += int(over - under + 1)
print(res % (10**9+7))

Solution (Python):
import sys

IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))

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 = [0]
    for i in range(n+1):
        d = dd_a[i] + dd[i]
        dd_a.append(d)
    
    dd_b = [0]
    dd_r = dd[::-1]
    for i in range(n+1):
        d = dd_b[i] + dd_r[i]
        dd_b.append(d)
    
    for i in range(k,len(dd_a)):
        cnt += dd_b[i]-(dd_a[i]-1)
    print(cnt%MOD)

if __name__ == '__main__':
    main()

Solution (Python):
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


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


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def debug(table, *args):
    ret = []
    for name, val in table.items():
        if val in args:
            ret.append('{}: {}'.format(name, val))
    print(' | '.join(ret), file=sys.stderr)


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False



def main():
    N, K = MI()
    ans = 0
    l = [i for i in range(N+1)]
    acc = list(accumulate(l))

    ans1 = 0

    for i in range(K, N+2):
        
        
        
        if i == N+1:
            mx = acc[N]
        else:
            mx = acc[N] - acc[N-i]
        mn = acc[i-1]
        
        
        
        
        
        
        ans1 += mx - mn + 1
        ans1 %= MOD
        

    print(ans1 % MOD)


if __name__ == '__main__':
    main()

Solution (Python):
N,K=map(int,input().split())
ans=0
mod=(10**9)+7
def ABC(N,K):
    mod=(10**9)+7
    a=((K-1)*K)//2
    b=(K*(2*N-K+1))//2
    s=b-a+1
    return s%mod

for i in range(K,N+2):
    ans+=ABC(N,i)

print(ans%mod)

Solution (Python):
MOD = 10**9 + 7
N, K = map(int, input().split())
ans = 0
for i in range(K, N+1):
    ans = (ans +(2*N+1-i)*i//2 - (i-1)*i//2 + 1) %MOD
ans += 1
print(ans%MOD)

Solution (Python):
M=10**9+7
n,k=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)

Solution (Python):
n, k = map(int, input().split())
MOD = 1000000007

ans = 0
for i in range(k, n+2):
    maxNum = i * (2 * n - (i - 1)) / 2
    minNum = i * (i - 1) / 2
    ans += (maxNum - minNum + 1) % MOD
print(int(ans) % MOD)

Solution (Python):
n,k = map(int, input().split())
mod = 10**9 + 7
ans = 0
for i in range(k,n+2):
    ans += i*n-i**2+i+1
    ans %= mod

print(ans)

Solution (Python):
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)


inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""
from collections import deque, defaultdict, Counter
import math
import sys
sys.setrecursionlimit(10 ** 7)


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



def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]


def ws(): return sys.stdin.readline().split()


def si(): return int(sys.stdin.readline())  


def ss(): return input()


def hi(n): return [si() for _ in range(n)]


def hs(n): return [ss() for _ in range(n)]  


def s_list(): return list(input())


def mi(n): return [wi() for _ in range(n)]  


def mip(n): return [wip() for _ in range(n)]


def ms(n): return [ws() for _ in range(n)]


def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[
    0]] for _ in range(n)]  


def grid(n): return [s_list() for _ in range(n)]


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    """a,bの最小公倍数"""
    return a * b // gcd(a, b)


def main():
    N, K = wi()
    mod = 10 ** 9 + 7
    s = 0
    s_1 = 0
    a = []
    b = 0
    ans = 0
    for i in range(N+1):
        b += i
        a.append(b)
    for i in range(K, N+1):
        s = a[i-1]
        s_1 = a[N]-a[N-i]
        ans += s_1-s + 1
    print(ans % mod + 1)


if __name__ == '__main__':
    main()

Solution (Python):
N,K = (int(x) for x in input().split())
N1 = N + 1
K1 = K - 1
setN = (((N1*N1*(N1+1))//2) - (N1*(N1+1)*(2*N1+1)//6) + N1) % 1000000007
setK = (((N1*K1*(K1+1))//2) - (K1*(K1+1)*(2*K1+1)//6) + K1) % 1000000007
print((setN-setK)%1000000007)

Solution (Python):
class Mint:
    
    MOD = 10**9+7
    
    def __init__(self, x=0):
        self.x = (x%self.MOD + self.MOD) % self.MOD
    
    def __iadd__(self, other):
        self.x += other.x
        if self.x >= self.MOD:
            self.x -= self.MOD
        return self
    
    def __isub__(self, other):
        self.x += self.MOD - other.x
        if (self.x >= self.MOD):
            self.x -= self.MOD
        return self
    
    def __imul__(self, other):
        self.x *= other.x
        self.x %= self.MOD;
        return self;
    
    def __add__(self, other):
        ans = Mint(self.x)
        ans += other
        return ans
        
    def __sub__(self, other):
        ans = Mint(self.x)
        ans -= other
        return ans
    
    def __mul__(self, other):
        ans = Mint(self.x)
        ans *= other
        return ans
    
    def __pow__(self, n):
        if n == 0:
            return Mint(1)
        a = self.__pow__(n >> 1)
        a *= a
        if n&1:
            a *= self
        return a
    
    def inv(self):
        return self**(self.MOD-2)
    
    def __ifloordiv__(self, other):
        self *= other.inv()
        return self
    
    def __floordiv__(self, other):
        ans = Mint(self.x)
        ans //= other
        return ans
        

    
def Main(N, K):
    ans = Mint(0)
    for i in range(K, N+2):


        ans += Mint(i)*Mint(N-i+1)+Mint(1)
    return ans.x

def main():
    N, K = map(int, input().split())
    print(Main(N, K))

if __name__ == '__main__':
    main()

Solution (Python):
n, k = map(int, input().split())
ans = 0

for i in range(k - 1, n + 1):
    ans += ((i + 1)*(n + n - i)//2)
for i in range(k - 1, n + 1):
    ans -= (i + 1)*i//2
ans += n + 2 - k
print(ans%(10**9 + 7))

Solution (Python):
N,K=map(int,input().split())
mod=10**9+7
Sum=0
for i in range(K,N+2):
    Min=i*(i-1)/2
    Max=N*(N+1)/2-(N-i)*(N-i+1)/2
    Dif=(Max-Min+1)%mod
    Sum=(Sum+int(Dif))%mod
    
print(Sum)

Solution (Python):
if __name__ == '__main__':
    s = input().rstrip().split(' ')
    N,K = int(s[0]), int(s[1])

    ret = 0

    for k in range(K,N+2):
        f = (k-1)*k/2
        t = N*k - k*(k-1)/2

        ret += t-f+1

    print(int(ret) % 1000000007)

Solution (Python):
N, M = map(int, input().split())

list=[]
a=1
for i in range(N+2):
    if i==0 or i==N+1:
        list.append(1)
    else:
        list.append(N*i+a)
        a-=2*i

ans=0
for i in range(M,N+2):
    ans+=list[i]

print(ans%1000000007)

Solution (Python):
N, K = map(int, input().split())
N += 1

A = [0] * N
ruiseki = [0] * N
for i in range(1, N):
    ruiseki[i] = ruiseki[i-1] + i

total = 0
for i in range(K, N):
    start = ruiseki[i-1]
    end = ruiseki[N-1] - ruiseki[N-i-1]
    total += end - start + 1


total += 1

mod = (10**9) + 7
print(total % mod)

Solution (Python):
N,K=map(int,input().split())
S=0
for s in range(K,N+2):
        S+=s*(2*N-s+1)/2-s*(s-1)/2+1
print(int(S)%(10**9+7))

Solution (Python):
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)

Solution (Python):
N, K = map(int, input().split())

ans = 0
for i in range(K, N+2):
  ans += int(i * (N-i+1) + 1)
  
print(ans % ((10**9)+7))

Solution (Python):
n, k = map(int, input().split())
sum = 0
for i in range(k, n + 2):
    sum += n * i - (i ** 2) + i + 1
print(sum % (10 ** 9 + 7))

Solution (Python):
N,K=map(int,input().split())

kaijo=[0]*(N+2)
kaijo[0]=1
kaijo[1]=1
s=0
rui=[0]*(N+2)
rui[0]=0
rev=[0]*(N+2)
rev[0]=N
for i in range(N+1):
    kaijo[i+1] *= (i+1)*kaijo[i]
    rui[i+1] += rui[i] + i+1
    rev[i+1] += rev[i] + (N-i-1)
    

for k in range(K,N+2):
    s += rev[k-1]-rui[k-1]+1

print(s%1000000007)

Solution (Python):
N,K = map(int,input().split())
Answer = 0
def f(x):
    return x*N - x*(x-1) +1
for i in range(K,N+2):
    Answer += f(i)
print(Answer %(10 ** 9 +7))

Solution (Python):
import scipy as sp
n, k = list(map(int, (input().split())))

k_list = sp.arange(k, n+2, dtype="int64")

k_list = n*k_list - k_list**2 + k_list + 1

ans = 0
for i in k_list:
    ans += i % (10**9 + 7)
    ans = ans % (10**9 + 7)

print(ans)

Solution (Python):
n, k = map(int, input().split())
sum = 0
for x in range(k, n + 2):
	sum += x * ((n + 1) - x) + 1

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

Solution (Python):
mod=10**9+7
n,k=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)

Solution (Python):
N,K = map(int,input().split())

dp = []
dp.append(K*(2*N-K+1)//2-K*(K-1)//2+1)
for k in range(K+1,N+1+1):
    s_min = k*(k-1)//2
    s_max =  k*(2*N-k+1)//2
    dp.append((dp[k-1-k]+s_max-s_min+1)%(10**9+7))

ans = dp[-1]
print(ans)

Solution (Python):
N, K = map(int, input().split())

first = 0
second = 0
result = 0
mod = 10 ** 9 + 7

for i in range(K):
    first += i
    second += N - i

result = (result + second - first + 1) % mod

for i in range(K, N + 1):
    first += i
    second += N - i
    result = (result + second - first + 1) % mod

print(result)

Solution (Python):
n,k = map(int,input().split())

m = 10**9 + 7





rr = 0
mx = 0
mn = 0
for i in range(k):
    mx += (n-i)%m
    mn += i%m




rr = mx-mn+1


pp = rr
for j in range(k+1,n+2):
    mn_p = j-1
    mx_p = n-j+1
    
    if(mx_p==0 or mn_p == n):
        pp += 1
        break
    else:
        pp += rr +mx_p - mn_p
        rr = rr +mx_p - mn_p
        
        
    
    
print(pp%m)

Solution (Python):
n, k = map(int, input().split())
mod = 1000000007
ans = 0

for i in range(k, n+2):
  i_num = ( i*n - ( i * (i-1) ) + 1 ) % mod
  ans += i_num
  ans %= mod

print(int(ans))

'''
1ko 0 -- n n+1 ko
2ko 1 -- 2n-1 2n-1 ko
3ko 3 -- 3n-3 3n-5 ko
4ko 6 -- 4n-6 4n-11 ko
k-ko sigma 1 - (k-1) -- k*n - sigma(1 - (k-1))
(sigma 1 - (k-1)) = k * (k-1) / 2
k-ko ippannsiki -> k*n - ( k * (k-1) )  + 1
'''

Solution (Python):
mod = 10**9+7
n,k = map(int,input().split())
ans = 0
lst1 = [i for i in range(n+1)]
lst2 = lst1[::-1]
s1 = [0]*(n+2)
s2 = [0]*(n+2)
for i in range(1,n+2): 
    s1[i] = (s1[i-1] + lst1[i-1])%mod
    s2[i] = (s2[i-1] + lst2[i-1])%mod
for i in range(k,n+2):
    ans += (s2[i] - s1[i] + 1)%mod
    ans %= mod
print(ans)

Solution (Python):
n,k=map(int,input().split())
ans=0
for i in range(k,n+2):
    count_min=int(i*(i-1)/2)
    count_max=int(i*(2*n-i+1)/2)
    ans+=count_max-count_min+1
    ans%=10**9+7
if ans<10**9+7:
    print(ans)
else:
    print(ans%10**9+7)

Solution (Python):
N, K = map(int,input().split())
mod = 10**9+7
res = 0
total = (N) * (N+1) // 2
for k in range(K, N + 2):
	tmp = k - 1
	X = tmp * (tmp + 1) // 2
	tmp = N-k
	Y = total - (tmp * (tmp + 1) // 2)
	res+= Y - X + 1
	res %= mod
print(res % mod)

Solution (Python):
N,K=input().split()
N=int(N)
K=int(K)
if (1<=N<=2*10**5)and(1<=K<=N+1):
    a=(N+1)*(N+1)*(N+2)/2-(1/6)*(N+1)*(N+2)*(2*N+3)+N-K+2-(N+1)*(K-1)*K/2+(K-1)*(2*K-1)*K/6
    a=int(a)
    a=a%(10**9+7)
    print(a)

Solution (Python):
n,k=map(int,input().split())
MOD=10**9+7

def S(a,MOD):
    x=[0]*(n+1)
    s=0
    for i in range(1,n+1):
        s+=i
        s%=MOD
        x[i]=s
    return x

ans=0
X=S(n,MOD)
for i in range(k,n+2):
    if i<n+1:
        m=X[n]-X[n-i]
        if m<0:
            m+=MOD
        ans+=(m+1-(X[i-1]-1+1))
    else:
        ans+=1
    ans%=MOD
print(ans)

Solution (Python):
N, K = map(int, input().split())
Z = 10**9+7

sum = 0

sum_A, sum_B = 0, 0
for i in range(1, K):
    sum_A += i-1
    sum_B += (N-i+1)

for i in range(K, N+2):
    sum_A += i-1
    sum_B += (N-i+1)
    sum += sum_B - sum_A + 1

print(sum % Z)

Solution (Python):
p = 226732710 
num = 10**9+7
[N,K] = [int(s) for s in input().rstrip().split(' ')]
L = []
ans = 0
for i in range(K,N+2):
    ans += i*(N-i+1)+1
    ans %= num
print(ans)

Solution (Python):
import math
import itertools
N, M = map(int,input().split())
s = 0

min = 0
max = 0
for j in range(M):
  min += j
  max += N-j
s = max - min + 1

for i in range(M+1, N+2):
  min += i
  max += N+2-i
  s += max - min + 1
  
print(s%(1000000000+7))

Solution (Python):
N,K = input().split()

CalcList = tuple(range(int(K), int(N)+2))
N = int(N)


ans = 0

for i in CalcList:
    tmp = 0
    min = i * (i-1) /2

    max = i * N -min


    tmp = max - min +1
    ans += tmp

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

Solution (Python):

from sys import stdin
from sys import setrecursionlimit


setrecursionlimit(10 ** 7)

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

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

point = 0

mod = 10**9+7

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

print(point)

Solution (Python):
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / math.gcd(n, m))


def coprimize(p, q):
    common = math.gcd(p, q)
    return (p // common, q // common)

mod = 10**9 + 7

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(lambda x,y : x * y % mod, range(n, n - r, -1), 1)
    denom = reduce(lambda x,y : x * y % mod, range(1, r + 1), 1)
    return (numer // denom ) % mod


def find_gcd(list_l):
    x = reduce(gcd, list_l)
    return x


def main():
    n,k = map(int,input().strip().split())
    
    
    
    
    
    

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



if __name__ == '__main__':
    main()

Solution (Python):
n, k = map(int, input().split())
dp_a = [0]*(n+1)
dp_b = [n]*(n+1)
mod = 10**9 + 7
l = [i for i in range(n+1)]
ll = [i for i in range(n, -1, -1)]
for i in range(1, n+1):
    dp_a[i] = (dp_a[i-1] + l[i])%mod
    dp_b[i] = (dp_b[i-1] + ll[i])%mod
ans = 0
for i in range(k, n+2):
    ans += (dp_b[i-1]-dp_a[i-1]+1)%mod
print(ans%mod)

Solution (Python):
N, K = tuple(int(s) for s in input().split())


sol = 0
MOD = (10**9) + 7
for k in range(K, N+2):
    sol += N*k - ((k)*(k-1)) + 1
sol = sol % MOD
print(sol)

Solution (Python):
def main(N=None, K=None):
    if not N:
        N, K = map(int, input().split())
    ans = (K-N-2)*(2*K*K-K*(N+2)-N*N-N-6)//6
    ans %= 10**9+7
    print(ans)
    return ans


if __name__ == "__main__":
    
    
    
    main()

Solution (Python):
n, k = map(int, input().split())
sum = 0
for i in range(k, n + 2):
    sum += n*i - (i  - 1)*i  +1
    
print(sum % (10**9 + 7))