peterverebics/CodeNet_Python_118 huggingface dataset:
from sys import stdin
input = stdin.readline

n, k = map(int, input().split())
cnt = 0
mod = 10 ** 9 + 7

for x in range(k, n + 2):
    cnt += x * n - x * (x - 1) + 1
    cnt %= mod

print(cnt)
n,k=map(int,input().split())
d,u=0,10**1000
ans=0
while d<u:
    d=(k*(k-1))//2
    u=(2*k*n-k**2+k)//2
    ans+=u-d+1
    k+=1
print(ans%(10**9+7))
def touSum(a,l):
    return int(((l-a+1)*(a+l))/2)

N,K = map(int,input().split())
maxSum = touSum(1,N)
#print(maxSum)
con = 0
for i in range(K,N+1+1):
    #print(str(i)+":"+str(touSum(1,i-1))+":"+str(touSum((1+N)-i,N)))
    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))
N, K = map(int, input().split())
MOD = 10 ** 9 + 7

LOW, HIGH = 0, N
ans = 0

if 1 >= K:
    ans += (HIGH - LOW + 1)

for i in range(2, N + 2):
    LOW += i - 1
    HIGH += N - i + 1
    LOW %= MOD
    HIGH %= MOD
    if i >= K:
        ans += (HIGH - LOW + 1)
        ans %= MOD

print(ans)
import itertools

N, K = map(int, input().split())
mod = (10 ** 9 + 7)

def calc(i):
    small = i * (i - 1) //2
    large = i * (2 * N - i + 1) // 2
    return large - small + 1

total = 0
for i in range(K, N+2):
    total += calc(i)
    total %= mod

print(total)
Mod = 1000000007

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

res  = 0

for i in range(k, n + 2):
    res += ((i * (n - i + 1)) % Mod);
    res += 1
    res %= Mod
print(res)
n, k = map(int, input().split())
mod = 10**9 + 7

ans = 0
for i in range(n - k + 2):
    start = ((k+i) * ((k+i) - 1)) // 2
    stop = (2 * n - (k+i) + 1) * (k+i) // 2
    ans += stop - start + 1
    ans %= mod
print(ans)
def main():
    N, K = map(int, input().split())
    MOD = 10**9 + 7
    ans = 0

    # 0, 0, 1, 3, 6, ...
    sub_sum = [0] * (N+2)
    for i in range(2, N+2):
        sub_sum[i] = sub_sum[i-1] + i-1
    
    for i in range(K, N+2):
        min_val = sub_sum[i]
        max_val = sub_sum[N+1] - sub_sum[N+1-i]
        ans += max_val - min_val + 1
        ans %= MOD
        
    print(ans)
if __name__ == "__main__":
    main()
N, K = map(int, input().split())

Sum = 0

for i in range(K, (N + 1) + 1):
    a = (((N - (i - 1)) + N) * i // 2) - ((i - 1) * i // 2) + 1
    #print(i,a,(((N  - (i - 1)) + N ) * i // 2),((i - 1) * i // 2))
    Sum = (Sum + a) % 1000000007

print(Sum)
n,k = map(int,input().split())
mod = 10**9+7
l = [i for i in range(n+1)]
rl = [i for i in range(n,-1,-1)]
suml = [0]*(n+1)
suml[0] = l[0]
for i in range(n):
    suml[i+1] = suml[i] + l[i+1]
sumrl = [0]*(n+1)
sumrl[0] = rl[0]
for i in range(n):
    sumrl[i+1] = sumrl[i] + rl[i+1]
cnt = 0
for m in range(k,n+2):
    max_m = sumrl[m-1]
    min_m = suml[m-1]
    cnt += max_m-min_m+1
print(cnt%mod)
n,k=map(int,input().split())
a=[i for i in range(n+1)]

b=[0]
c=[a[-1]]
for i in range(1,n+1):
    b.append(i+b[i-1])
    c.append(c[i-1]+(n-i))


if n+1==k:
    print(1)
else:
    s=0
    for i in range(k-1,n+1):
        s+=abs(b[i]-c[i])+1
    print(s%1000000007)
N, K = map(int, input().split())

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

print(ans % (10**9 + 7))
n,k = map(int,input().split(' '))
ans = n*(-k*(k-1)//2+(n+2)*(n+1)//2) + k*(k-1)*(2*k-1)//6 - k*(k-1)//2 - (n+1)*(n+2)*(2*n+3)//6 + (n+1)*(n+2)//2 + n-k+2
print(ans%(pow(10,9)+7))
n, k = map(int, input().split())

ans = 0

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

print(ans)
N, K = map(int, input().split())


def sub_sum(l, r):
    return (l + r) * (r - l + 1) / 2


ans = 0

for i in range(K, N+2):
    l = sub_sum(0, i-1)
    r = sub_sum(N-i+1, N)
    ans += r - l + 1

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

print(int(ans))
n,k=map(int,input().split())
b=0
for i in range(k,n+2):
  x=0.5*i*(i-1)
  b+=i*n-2*x+1
print(int(b%(10**9+7)))
import math
N,K=map(int,input().split())

sum=0
for i in range(K,N+2):
#  print(N*(N+1)//2-((N-i)*(N-i+1)//2),i*(i-1)//2)
  sum+=(N*(N+1)//2)-((N-i)*(N-i+1)//2)-(i*(i-1)//2)+1
  sum%=(10**9+7)
print(sum%(10**9+7))
n, k = map(int, input().split())
ans = 0
mod = 10**9+7
for i in range(k, n+2):
    min_sum = (i-1)*i/2
    max_sum = (n+n+1-i)*i/2
    ans += max_sum - min_sum + 1
print(int(ans)%mod)
n,k=map(int,input().split())
res=0
for i in range(k,n+2):
  res+=(2*n-i+1)/2*i-(i/2*(i-1))+1
  #print(res)
print("{}".format(int(res%(10**9+7))))
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)
def calc(a):
    sml = (0 + a-1) * a //2
    lar = sml + a*(n-a+1)
    return lar - sml + 1
ans = 0
mod = 10**9 + 7
n,k = map(int,input().split())
for i in range(k,n+2):
    ans += calc(i) % mod
print(ans % mod)
n,k=[int(_) for _ in input().split()]
mod=10**9+7
ans=0
for i in range(k,n+2):
    a=i*(i-1)//2
    b=i*(2*n-i+1)//2
    ans += b-a+1
print(ans%mod)
import sys
input = lambda: sys.stdin.readline().rstrip()
inp = sys.stdin.buffer.readline                                
def I(): return list(map(int,inp().split()))
m=10**9+7

n,k=I()
ans=1 
for i in range(k,n+1):
    ans+=i*(n-i+1)+1
    ans%=m
print(ans)
N, K = map(int, input().split())

lst = [i for i in range(N+1)]
lst1 = lst[::-1]

ans = 0
mod = 10**9+7
tmp = sum(lst[:K-1])
tmp1 = sum(lst1[:K-1])

for i in range(K-1, N+1):
    tmp += lst[i]
    tmp1 += lst1[i]
    ans += (tmp1-tmp+1)
print(ans%mod)
from sys import stdin, stdout
import math
import bisect
import queue

N, K = map(int, stdin.readline().strip().split())

ans = 0

for l in range(K, N + 2):
    fi = ((-1 + l) * l) // 2
    se = ((N + (N - l + 1)) * l) // 2
    ans += se - fi + 1
    ans %= 1000000007
    
stdout.writelines(str(ans) + '\n')
# ABC163

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

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

print(ans)
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)
n, k = map(int,input().split())
ans = 0
for i in range(k,n+2):
    ans += (n+n-i+1)*i/2 - (i-1)*i/2 + 1
print(int(ans%(10**9+7)))
N, K = map(int, input().split())
MAX = 10 ** 9 + 7
 
res = 0
 
def calc_sum(l, r):
  return ((l+r) * (r-l+1)) // 2
 
for i in range(K, N+2):
  low = calc_sum(0,i-1)
  high = calc_sum(N-i+1,N)
  res = (res + (high-low+1)) % MAX
 
print(res)
N, K= map(int, input().split())
answer = 0
n_list = [0]*(N+1)
n_list[0] = 0
for i in range(1,N+1):
    n_list[i] = n_list[i-1]+i

for k in range(K,N+1):
    large = n_list[N]-n_list[N-k]
    small = n_list[k-1]

    answer += large-small+1
answer += 1
print(answer % 1000000007)
N,K = map(int, input().split())

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

print(ans%(10**9+7))
N, K = 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)
N,K=map(int,input().split())

result=0

teisu=10**9+7

for i in range(K,N+2):
    a=-i**2+(N+1)*i+1
    result+=a
    result=result%teisu

print(result)
# n= int(input())
# import math
# s =input()
n,k = map(int, input().split())
# a = list(map(int, input().split()))
# a,b = map(str, input().split())
# ab = [list(map(int,input().split())) for _ in range(n)]

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

for i in range(K,N+2):
    a = i * (N + 1 - i) + 1
    a %= mod
    ans += a
    ans %= mod

print(ans)
import itertools
mod=10**9+7
n,k=map(int,input().split())
A=range(n+1)
b = [0] + list(itertools.accumulate(A))
ans=0
for i in range(k,n+2):
    ans+=b[-1]-b[-1-i]-b[i]+1
print(ans%mod)
mod=10**9+7
n,k=map(int,input().split())
ans=0
for i in range(k,n+2):
    ans+=n*i-i*(i-1)+1
    ans%=mod
print(ans)
mod = int(1e9) + 7

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

    small = 0
    large = 0
    ans = 0
    for i in range(0, n+1):
        small += i
        large += n-i
        if i+1 >= k:
            ans = (ans + (large - small + 1)) % mod

    print(ans)


if __name__ == '__main__':
    main()
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)
n,k = map(int,input().split())
count = 0
for i in range(k,n+2):
    count += i*(n-i+1)+1
    count %=(10**9+7)
print(count)
n,k = map(int, input().split())
t = 0
for i in range(k, n+2):
  up = i*(2*n +1 -i)/2
  down = i*(i-1)/2
  s= up - down + 1 
  t += s
ans = t % (10**9 +7)
print(int(ans))
from math import factorial

N,K=map(int,input().split())

ans=0
i=K
while i<=N+1:

    mni=i*(i+1)//2
    mxi=i*(2*N-i+3)//2
    ans+=mxi-mni+1
    i+=1

print(ans%(10**9+7))
n,k = map(int, input().split())

mod = 10**9+7
a = 10 ** 100 % mod

def calc(n, k):
  return (2*n-k+1) * (k // 2) if k % 2 == 0 else (2*n-k+1) * (k // 2) + (n + (n-k+1)) // 2

def choose(n, k):
  x1 = calc(n, k)
  x2 = calc(k-1, k)
  return (x1 - x2 + 1) % mod

res = 0
for i in range(k, n+2):
  a = choose(n, i)
  res += a
  res %= mod

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

ans = 0
mod = 10**9+7

for i in range(k,n+2):
    # print((n*(n+1)/2 - (n-i)*(n-i+1)/2 - (i-1)*i/2 +1))
    ans += int((n*(n+1)/2 - (n-i)*(n-i+1)/2 - (i-1)*i/2 +1))

if ans >= mod:
    print(ans%mod)
else:
    print(ans)
n, k = map(int, input().split())

p = 10 ** 9 + 7
s = 0


for r in range(k, n + 2):
    min_val = (r - 1) * r // 2
    max_val = (n - r + 1 + n) * r // 2
    s += (max_val - min_val + 1)
    s %= p

print(s)
N, K = map(int, input().split())
ans = 0
for i in range(K,N+2):
	ans += (i*(N-i+1)+1)
print(ans%(10**9+7))
n,k=map(int,input().split())
summin=0
for i in range(k-1):
    summin+=i
summax=0
for i in range(k-1):
    summax+=(n-i)
ans=0
for x in range(k,n+2):
    summin+=(x-1)
    summax+=(n-(x-1))
    ans+=(summax-summin+1)
    ans%=(10**9+7)
print(ans)
def main():
    n,k=map(int,input().split())
    mod=10**9+7
    if n-k==-1:
        print(1)
    else:
        ans=(n+2*k)*(n-k+1)*(n-k+2)//6+n-k+2
        print(ans%mod)
if __name__=="__main__":
    main()
n,k=map(int,input().split())
DIV = 10**9+7

count = 0
for i in range(k,n+2):
  min_k = i*(i-1)/2
  max_k = i*(2*n-i+1)/2
  count += max_k - min_k + 1
print(int(count % DIV))
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

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

if __name__ == '__main__':
    main()
N, K = map(int, input().split())
MOD = 10 ** 9 + 7

low, high = 0, 0
ans = 0
for i in range(1, N + 2):
    low += i - 1
    high += N - i + 1

    if i >= K:
        ans += (high - low + 1)
        ans %= MOD

print(ans)
N,K=map(int,input().split())

M=N+1

A=-M*(M+1)*(2*M+1)//6+(N+1)*M*(M+1)//2+M

M=K-1

B=-M*(M+1)*(2*M+1)//6+(N+1)*M*(M+1)//2+M


print((A-B)%(10**9+7))
n,k=map(int,input().split())
ans=0
for i in range(k,n+2):
    ans+=i*(n-i+1)+1
mod=10**9+7
ans=ans%mod
print(ans)
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter
from operator import mul
from functools import reduce

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

a = n*(n+k+1)*(n-k+2)//2
b = n-k+2
c = -((n+2)*(n+1)*n - k*(k-1)*(k-2))//3

print((a+b+c) % (10**9+7))
N,K=map(int,input().split())
s=1

def tousa(l,r):
    return((l+r)*(r-l+1)//2)

for i in range(K,N+1):
    s+= (tousa(N-i+1, N) - tousa(0, i-1) + 1)
# print(s)
print(s%(10**9+7))
N,K = map(int,input().split())
mod = 10**9+7
def func(a,n):
    if n == 1:
        return a%mod
    elif n%2:
        return (a*func(a,n-1))%mod
    else:
        return ((func(a,n//2))**2)%mod
ans = 0
sum1 = 0
sum2 = 0
for i in range(1,N+2):
    if i == K:
        diff = ans
    sum1 = (sum1 + i-1)%mod
    sum2 = (sum2 + N-i+1)%mod
    ans = (ans + sum2 - sum1 + 1)%mod
print((ans-diff)%mod)
N,K=map(int,input().split())
MOD=10**9+7
ans=0
for k in range(K,N+2):
    ans+=N*k+1-k*k+k
    ans%=MOD
print(ans)
N, K = map(int, input().split())
mod = int(1e9) + 7
S = (N * (N + 1) * (N + 2) - (3 * N - 2 * K + 4) * K * (K - 1)) // 6 + N - K + 2
print(S % mod)
N,K=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)
n,k=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))
#l=int(input())
n,k=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)
n, k = map(int,input().split())

lst = [_ for _ in range(n+1)]
ans = 0

for i in range(k,n+2):
    min_value = i*(i-1)//2
    max_value = (i*(2*n - i + 1))//2
    ans += max_value - min_value + 1

print(ans % (10**9 + 7))
# print('input >>')
N, K = map(int,(input().split()))

MOD = 10**9+7

# print('-----output-----')
ans = 0
for n in range(K, N+2):
    max_ = n * (N-n+1 + N) // 2
    min_ = n * (0 + n-1) // 2
    # print(n, max_, min_)
    ans += max_ - (min_ -1)

print(ans % MOD)
N,K = 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)
N, K = map(int, input().split())

mod = 10 ** 9 + 7
ans = 0

for k in range(K, N + 2):
    last = k * N - k * (k - 1) // 2
    init = N + k * (k - 1) // 2
    ans += init - k * (k - 1) // 2 + 1 + (last - init)
    ans %= mod
    
print(ans)
n, k = map(int, input().split())

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

print(c % (10 ** 9 + 7))
def main():
  N, K = (int(_) for _ in input().split())
  MOD = 10 ** 9 + 7
  res = 0
  for k in range(K, N+2):
    res += k * (N - k + 1) + 1
    res %= MOD
  print(res)
  return

if __name__ == '__main__':
  main()
n, k = map(int, input().split())
ans = 0

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

print(ans%(10**9 + 7))
N, K = 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)
po=pow(10,9)+7
n,k=map(int,input().split())
cc=0
for i in range(k,n+2):
  cc+=(n*i-i*(i-1)+1)%po
print(cc%po)
# int(input()) # 入力が1つ
from collections import defaultdict
n, k = map(int, input().split()) # 入力が複数
# [int(i) for i in input().split()] # 配列で数字
mod = 10 ** 9 + 7
cum = [0] + [i for i in range(n + 1)]
for i in range(n + 1):
    cum[i + 1] += cum[i]

ans = 0
for i in range(k, n + 2):
    MIN = cum[i]
    MAX = cum[n + 1] - cum[n + 1 - i]
    ans += (MAX - MIN + 1) % mod
print(ans % mod)
n, k = map(int, input().split())
mod = 10**9+7
ans = 0
for i in range(k, n+2):
    ans += (2*n-i+1)*i//2 - (i-1)*i//2 + 1
    ans %= mod
print(ans)
import numpy as np
N, M = map(int, input().split())
A = np.asarray(range(N+1), dtype=np.int64)
MOD = 10**9+7
S, E = (N/2) * (N+1), (N/2) * (N+1)
result = 1
for i, j in zip(range(N - M + 1), range(N, -1, -1)):
    S = S - i
    E = E - j
    # print(S, E)
    result += (S - E + 1) % MOD
    result %= MOD
    # print(result)
print(int(result))
N, K = map(int, input().split())
min_val = 0
max_val = 0
for i in range(K):
    max_val += N - i
    min_val += i
# print(min_val)
# print(max_val)

ans = 0
mod = 10 ** 9 + 7
for i in range(K, N + 2):
    ans += max_val - min_val + 1
    ans %= mod
    min_val += i
    max_val += N - i
print(ans)
INF = 10 ** 9 + 7
N, K = map(int, input().split())

ans = 0
mx = 0
mn = 0

for i in range(N+1):
  mx += N-i
  mn += i
  if i + 1 >= K:
    ans += (mx - mn + 1) % INF

print(ans % INF)
n,k=map(int,input().split())
MOD=10**9+7
t=[]
r=[]
for i in range(0,n+1):
    t.append(i)
for i in range(n,-1,-1):
    r.append(i)

fr=0
af=0
for i in range(0,k-1):
    fr+=t[i]
    af+=r[i]

ans=0
for i in range(k-1,n+1):
    fr+=t[i]
    #print(fr)
    af+=r[i]
    ans+=(af-fr+1)%MOD

print(ans%MOD)
N,K=map(int,input().split())
sum=0
for i in range(K,N+2):
  sum+=((2*N-i+1)*i//2-i*(i-1)//2+1)%(10**9+7)
print(sum%(10**9+7))
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
  #print(MIN,MAX)
  ans+=(MAX-MIN+1)%mod
  ans%=mod
print(ans)
N, K = map(int, input().split())
count = 0

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

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

M = 10**9 + 7

cnt = 1

a = 0
b = N
c = 0

for i in range(N - K + 1):
    cnt += b - a + 1
    c += 1
    a += c
    b += N - c


print(cnt % M)
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))
N,K=map(int,input().split())
A=[0]*(N+1)
for i in range(N+1):
    A[i]=i
ans=0

B=[0]*(N+2)
for i in range(N+1):
    B[i+1]=B[i]+A[i]

while True:
    if K>N+1:
        break
    else:
        ans+=B[-1]-B[N-K+1]-B[K]+1
        K+=1

print(ans%(10**9+7))
from math import factorial
N, K = map(int, input().split())

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

    tmp_min = (i - 1) * i / 2
    tmp_max = (N * (N + 1) / 2) - ((N - i) * (N - i + 1) / 2)
    # print(tmp_min, tmp_max)

    tmp = tmp_max - tmp_min + 1
    ans += tmp

print(int(ans % (10**9+7)))
n, k = map(int,input().split())

count = 0
for i in range(k, n+2):
    mn = (i - 1) * i / 2
    mx = (2 * n - i + 1) * i / 2
    count += mx - mn + 1
print(int(count % 1000000007))
import sys
N, K = list(map(int, input().split()))
MOD = 10 ** 9 + 7

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

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

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

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

ans = 0
for i in range(k,n+2):
    min_num = (0+i-1)*i//2
    max_num = (n+(n-i+1))*i//2
    ans += (max_num - min_num + 1) % mod
print(ans % mod)
import math
import queue
 
def readInt():
	return int(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))
N, K = map(int, input().split())
mod = 10**9 + 7
count = 0
for n in range(K, N+2):
  maxSum = (n*(N + N-n+1))//2
  minSum = (n*(n-1))//2
  count += maxSum - minSum + 1
  count %= mod

print(count)
N, K  = map(int, input().split())

ans = 0
for i in range(K, N+2):
    minN = (i-1) * i //2
    maxN = (2*N-i+1) * i //2
    ans += (maxN - minN + 1) % (pow(10,9)+7)

print(ans % (pow(10,9)+7))
N,K = map(int, input().split())

S = [0]*(N+1)
S[0] = 0
for n in range(1,N+1):
    S[n] = S[n-1]+n

ans = 0
for k in range(K, N+1):
    ans += ((S[N]-S[N-k])-(S[k-1]))+1
    ans %= (10**9+7)

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

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

n, k = map(int, input().split())
l = [0] * ((n + 1) // 2)
l[0] = n + 1
ans = 0

for i in range(1, (n + 1) // 2):
    l[i] = (l[i - 1] + (n - i * 2)) % MOD

for i in range(k, n + 1):
    if i <= (n + 1) // 2:
        ans += l[i - 1]
    else:
        ans += l[n - i]
    ans %= MOD

print((ans + 1) % MOD)
M = 10**9 + 7
n, k = [int(c) for c in input().split()]
out = 0
for kk in range(k, n+2):
    mm = kk * (kk-1) / 2
    MM = kk * (2*n - kk +1) / 2
    out += (MM - mm + 1)
    out %= M
print(int(out % M))
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)
    # print(t)
    t%=M
    ans +=t+1
    ans%=M
    # print(00,sum(range(N-i+1,N+1)),sum(range(0,i)))


print(ans+1)
# coding: utf-8


def solve(*args: str) -> str:
    n, k = map(int, args[0].split())
    ret = 1
    p = 10**9+7
    for i in range(k, n+1):
        ret += (n+(n-i+1))*i//2
        ret -= (i*(i-1)//2-1)
        ret %= p

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))
N, K = map(int, input().split())
# 小さい方から順にk個とったものと、大きい方から順にk個とったものの差
# １刻みから作る最小と最大間は、全てを満たす


def calc(x, N):
    a = x * (x - 1) // 2
    b = (2 * N - x + 1) * x // 2
    return b - a + 1


tot = 0
for i in range(K, N + 2):
    ans = calc(i, N)
 #   print(ans)
    tot += ans

aa = tot % (10 ** 9 + 7)

print(aa)
n, k = map(int, input().split())
mod = 10**9 + 7

MAX = sum([i for i in range(n-k+1, n+1)[::-1]])
MIN = sum([i for i in range(k)])

ans = MAX - MIN + 1
for i in range(k, n+1):
    MAX+=n-i
    MIN+=i
    ans += MAX - MIN + 1
    ans%=mod

print(ans)
n , k = map(int, input().split())
ans = 0
MOD = int(1e9+7)
for i in range(k, n + 2):
    r = (2*n-i+1) * i // 2
    l = (i - 1) * i // 2
    ans += r - l + 1
print(ans % MOD)
def main():
    import sys
    input = sys.stdin.readline
    from math import factorial
    mod = 10**9 + 7
    N, K = map(int, input().split())
    ans = 0
    for i in range(K, N+2):
        ans += i * ((2 * N + 1) - i) // 2 - i * (i - 1) // 2 + 1 
        ans %= mod
    print(ans%mod)


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

MOD = 10**9+7
cnt = 0

for i in range(k, n+2):
    min_sum = i*(i-1)//2
    max_sum = i*n - i*(i-1)//2
    cnt += max_sum - min_sum + 1
    cnt = cnt % MOD

print(cnt)
N,K = map(int, input().split())
Cseq = [i for i in range(N+1)]
CCseq = [0]
for i in range(1,N+1):
    CCseq.append(Cseq[i] + CCseq[-1])
ans = 1
for i in range(K,N+1):
    ans += CCseq[-1]-CCseq[len(CCseq)-1-i]-CCseq[i-1]+1
print(ans % (10**9+7))
n,k = map(int, input().split())
ans = 0
for i in range(k,n+2):
  a = (i-1)*i//2
  ans += n*i-2*a+1
print(ans%(10**9+7))
def d_sum_of_large_numbers(MOD=10**9 + 7):
    N, K = [int(i) for i in input().split()]
    return (N + 2 - K) * (N**2 + (K + 1) * N - 2 * K**2 + 2 * K + 6) // 6 % MOD

print(d_sum_of_large_numbers())
N,K = map(int,input().split())

mod = int(1e9+7)

##O(K)
upper = 0
for i in reversed(range(N+1-K,N+1)):
    upper += i
upper_point = N-K
##O(K)
lower = 0
for i in range(K):
    lower += i
lower_point = K
ans = 0

for i in range(K,N+2):
    ##print("N:",i,upper-lower+1)
    
    ans += upper - lower + 1
    upper += upper_point
    lower += lower_point

    upper_point -= 1
    lower_point += 1

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