peterverebics/CodeNet_Python_118 huggingface dataset:
#n=int(input())
n,k=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)
n,k = map(int,input().split())

ans=0
mod = 10**9+7
for i in range(k,n+2):
  a0=(i*(i-1))//2
  an=i*n-a0
  ans+=an-a0+1

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

m = 1000000007

result = 0
for i in range(K, N + 2):
    # max: N, N -1, ..., N - i + 1
    a = (N + (N - i + 1)) * i // 2
    # min: 0, 1, .., i - 1
    b = (0 + (i - 1)) * i // 2
    result += a - b + 1
    result %= m
print(result)
def main():
    MOD = 10 ** 9 + 7

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

    ans = 0
    low = sum(range(K - 1))
    high = sum(range(N - K + 2, N + 1))
    for take in range(K, N + 2):
        low += take - 1
        high += N - (take - 1)
        ans = (ans + high - low + 1) % MOD
    print(ans)


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()
import sys
input = sys.stdin.buffer.readline

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

min_lis = [0] * (N + 2)
max_lis = [0] * (N + 2)

for i in range(1, N + 2):
    min_lis[i] = min_lis[i - 1] + (i - 1)
    max_lis[i] = max_lis[i - 1] + (N - i + 1)

answer = 0
for k in range(K, N + 2):
    answer += max_lis[k] - min_lis[k] + 1
print(answer % MOD)
n, k = map(int,input().split())

cnt = 0

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

print(cnt % (10**9 + 7))
N , K =map(int,input().split())
MOD=10**9+7
ans=0
if N<K:
    print(1)
else:
    tmp_low = sum(range(K))
    tmp_high = sum(range(N-K+1,N+1))
    r=tmp_high-tmp_low+1
    ans+=r
    ans%=MOD
    for sel in range(K+1,N+2):
        tmp_low += sel-1
        tmp_high += N-sel+1
        r= tmp_high-tmp_low+1
        ans+=r
        ans%=MOD
    print(ans%MOD)
n,k = map(int,input().split())
c = 0
for i in range(k,n+2):
  c += i*(n-i+1)+1
  c = c%(10**9+7)
print(c)
N, K = map(int, input().split())

MOD = 10 ** 9 + 7
count = [0] * (N + 1)
for i in range(1, N + 1):
    count[i] += count[i - 1] + i
    count[i] %= MOD

ans = 1
for k in range(K, N + 1):
    ans += count[-1] - count[-k - 1] - count[k - 1] + 1
    ans %= MOD
print(ans)
N,K = map(int,input().split())
l = list()
for i in range(K,N+2):
    min = i*(i - 1)/2
    max = (2*N - i + 1)*i /2
    cases = max - min + 1
    l.append(cases)
print(int(sum(l)) % (10**9 + 7))
import numpy as np

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

a = np.arange(n+1, dtype='int')

b = np.cumsum(a)

s = 0

for i in range(k, n+1):
	s += (b[n] - b[n-i]) - b[i-1] + 1
	s = s % 1000000007

s += 1
s = s % 1000000007
print(s)
MOD=10**9+7
N, K=map(int,input().split())
ans=0
for i in range(K, N+2):
    mi=i*(i-1)//2
    ma=(2*N-i+1)*i//2
    ans+=(ma-mi+1)
    ans%=MOD
print(ans)
N, K = map(int, input().split())
mod = 10**9 + 7
ans = 0
for i in range(K, N+2):
  mi = N-i+1
  ma = N
  s_max = ((mi+ma)*i)//2
  mi = 0
  ma = i-1
  s_min = ((mi+ma)*i)//2
  #print(s_min, s_max)
  ans += (s_max-s_min+1)
  ans %= mod

print(ans)
n,k = map(int,input().split())
n += 1
p = 0
for i in range(k,n+1):
    p += i * (n - i)+1
    p %= 1000000007
print(p)
MOD = 10 ** 9 + 7

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

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

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

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

print(ans)
N,K = map(int,input().split())
sum_ans = 0
 #get "ruisekiwa"
c_sum = [0]*(N+2)
for i in range(N+1):
    c_sum[i+1]+=c_sum[i]+i

for i in range(K,N+2):
    sum_ans+= ((c_sum[N+1]-c_sum[N+1-i])-(c_sum[i]-c_sum[0])+1)
print(sum_ans%(10**9+7))
N,K = map(int,input().split())
MOD = 10**9 + 7

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


ans = 0
for i in range(K,N+2):
    a = sum_lr(N-(i-1),N)
    b = sum_lr(0,i-1)
    temp = a - b + 1
    # print('i',i)
    # print(a)
    # print(b)
    # print(temp)
    ans += temp
    ans %= MOD
print(ans)
n, k = list(map(int, input().split()))

sums = 0
for i in range(k, n+2):
	sums += i*(n + 1 - i) + 1
	
print (sums % (10**9 + 7))
def main():
    n, k = map(int, input().split())
    sum_min = 0
    sum_max = 0
    ans = 0
    m = 10**9 + 7
    for i in range(k-1):
        sum_min += i
        sum_max += n-i
    for i in range(k-1, n+1):
        sum_min += i
        sum_max += n-i
        ans += sum_max - sum_min + 1
        ans %= m
    print(ans)
    

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

ans = 0
c = 0   #combination
l = 0
h = 0
for i in range(1, n+2): #O(n)
    l += i - 1
    h += n + 1 - i
    c = (h - l + 1) % mod
    if i >= k:
        ans = (ans + c) % mod
    else:
        pass
print(ans)
N,K = map(int,input().split())
ans = 0
for k in range(K,N+2):
    ans += N*k-k*(k-1)/2-k*(k-1)/2+1
ans %= 10**9+7
print(int(ans))
N, K = map(int, input().split())
count = 0
for i in range(K,N+2):
    count += N*i-i**2+i+1
print(count%(10**9+7))
N, K = map(int, input().split())
mod = 10**9 + 7 
ans = 0 
for i in range(K, N + 2): 
        ans += (((N*(N + 1) // 2) - ((N - i)*(N - i + 1) // 2)) - ((i - 1)*i // 2) + 1) % mod 
print(ans % mod)
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)
n, k = map(int, input().split())
pos_num = []
for i in range(n+2):
    st_num = int((i*(i-1))/2)
    ed_num = int(((2*n-i+1)*i)/2)
    # print(i,st_num,ed_num)
    pos_num.append(ed_num-st_num+1)
print(sum(pos_num[k:])%(10**9+7))
n, k = map(int, input().split())
table = [i for i in range(n+1)]
mod = 10**9 + 7
mx, mn = int((1/2)*k*(table[-k] + table[-1])), int((1/2)*k*(table[0] + table[k-1]))
ans = mx - mn + 1

for i in range(k+1, n+2):
    mx += table[-i]
    mn += table[i-1]
    ans += mx - mn + 1
print(ans%mod)
n , k = map(int, input().split())
ans=0
for i in range(k,n+2):
    ans+=n*i-i**2+i+1
    ans%=1000000007
print(ans)
n, k = map(int, input().split())
ans = 0
for i in range(k, n+2):
    ans += i*n-i**2+i+1
mod = 10**9+7
print(ans%mod)
N,K = list(map(int,input().split()))
ans = 0
for i in range(K,N+2):
    ans += ((((N*2)-i+1)*i//2) - ((i-1)*i//2) +1)
print(ans%(10**9+7))
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)
n, k = [int(i) for i in input().split()]
mod = 10**9 + 7
ans = 0

for i in range(k, n + 2):
    first = i * (i - 1) / 2
    final = (n * 2 - i + 1) * i / 2
    add = final - first + 1
    ans = (ans + add) % mod

print(int(ans))
N, K = map(int,input().split())
MOD = 10**9+7
ans = 0

for i in range(K, N + 2):
    MIN = (i * (i - 1))//2
    MAX = (N * i) - MIN #例えば10,9,8なら(10-0),(10-1),(10-2)
    ans += MAX - MIN + 1
    ans %= MOD
print(ans)
n, k = map(int, input().split())

c = 0

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

print(int(c%(10**9 + 7)))
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

MOD = 10 ** 9 + 7
N, K = lr()
answer = 0
for i in range(K, N+2):
    low = i * (i-1) // 2
    high = i * (N+N-i+1) // 2
    answer += high - low + 1
    answer %= MOD

print(answer%MOD)
N,K = map(int,input().split())
MOD = 10**9+7
res = 0
curmin,curmax = 0, N
mini,maxi = 1, N-1
for i in range(1,N+2):
  if i == N+1:
    # print(1)
    res += 1
  else:
    if i >= K:
      # print(curmin,curmax)
      res = (res + curmax - curmin + 1) % MOD
    curmin += mini
    curmax += maxi
    mini += 1
    maxi -= 1

print(res % MOD)
from math import ceil
N, K = [int(i) for i in input().split()]
mod = 10 ** 9 + 7
ans = 0
n = m = 0
for i in range(1, N + 2):
    n += N + 1 - i
    m += i - 1
    if i >= K:
        ans += n - m + 1
        ans %= mod
print(ans)
def main():
    n, k = [int(e) for e in input().split()]
    mod = 10 ** 9 + 7

    ans = 0
    for ki in range(k, n + 2):
        ans += n * (n + 1) // 2 - (n - ki) * (n - ki + 1) // 2 - \
            (ki * (ki + 1) // 2 - ki) + 1
        ans %= mod

    print(ans)


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

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

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

ans = 0
for k in range(K, N+2):
    ans = (ans + k*N - k*(k-1) + 1) % MOD
#     print(k*(k-1)//2, k*N - k*(k-1)//2)
print(ans)
# しゃくとり

mod = 10**9 + 7

n,k = 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)
N, K = map(int,input().split())
ans = 0
MOD = int(1E+9 + 7)
for n in range(K,N+2):
    x = (N+1-n) * n + 1
    ans += x
    ans %= MOD
print (ans)
n, k = map(int, input().split())
min = [0] * (n + 1)
max = [0] * (n + 1)
min[0] = 0
max[0] = n
for i in range(1, n + 1):
    min[i] = min[i - 1] + i
    max[i] = max[i - 1] + n - i

# print(min)
# print(max)
sum = 0
for i in range(k - 1, n + 1):
    sum = sum + max[i] - min[i] + 1
print(sum % (pow(10, 9) + 7))
MOD = 10**9 + 7
N, K = list(map(int, input().split()))

ans = 0

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

l_sum = sum(n[:K])
r_sum = sum(n[-K:])

l = K
r = N-K

for i in range(K, N+1):
    ans = (ans + r_sum - l_sum + 1) % MOD
    
    l_sum += n[l]
    r_sum += n[r]
    
    l += 1
    r -= 1
    
print((ans+1)%MOD)
N,K = map(int,input().split())

mod = 10**9+7
ans = 0

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

ans = 0
a = 1

for i in range(1, n + 2):
  a -= 2 * (i - 1)
  if i >= k:
    ans += (i * n + a)
    ans %= MOD
print(ans)
n, k = [int(x) for x in input().split()]

res = 0
for i in range(1, n+2):
    if i < k:
        continue
    max_sum = -(i**2)/2 + n*i + i/2
    min_sum = (i**2)/2 - i/2
    res += max_sum - min_sum + 1
    res = res % (10**9+7)
print(int(res))
import math

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

mod = 10**9 +7

sn = (n*(n+1)*(n+2)/6 +n+1)% mod
sk = ((k-1)*k*(3*n-2*k+4)/6 +k-1)% mod

snk = math.floor((sn - sk)% mod)

print(snk)
import itertools
N, K = map(int, input().split())
t = 0
for i in range(K,N+2):
    st = int((i*(0+i-1))/2)
    ed = int((i*(N-i+N+1))/2)
    t += (ed - st + 1)
    t %= 10**9 + 7
print(t)
import sys
def input():
    return sys.stdin.readline()[:-1]


def main():
    N, K = map(int,input().split())
    mod = 10 ** 9 + 7
    ans = 0
    for i in range(K, N + 1 + 1):
        mi = int((i - 1) * i / 2)  #ma、miは i * (10 **100)を無視した上限下限
        ma = i * N - mi
        ans += ma - mi + 1
    print(ans % mod)


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

ans = 0
for i in range(k,n+1) :
  # i個使う場合の最小値
  min_i = (i-1)*i//2
  # i個使う場合の最大値
  max_i = (n-i+1+n)*i//2
  ans += (max_i-min_i+1)
  
print(ans%(10**9+7)+1)
def resolve():
    n, k = map(int, input().split())
    a=0
    for i in range(k,n+2):
        a+=(n*(n+1)/2)-((n-i)*(n-i+1)/2)
        a-=(i-1)*i/2-1
    print(int(a%(10**9+7)))
resolve()
#!/usr/bin/python3

from functools import reduce
from operator import add
import sys


def main():
    N, K = map(int, input().split(' '))
    sys.setrecursionlimit(N + 50)

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


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

n_list=list(range(n+1))

saisyou=sum(n_list[0:k])
saidai=sum(n_list[n-k+1:n+1])

ans=saidai-saisyou+1

for i in range(k+1,n+2):
    saisyou+=n_list[i-1]
    saidai+=n_list[-(i)]
    ans+=saidai-saisyou+1
    ans%=10**9+7

print(ans)
# D - Sum of Large Numbers

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

modulus = 10 ** 9 + 7

s = 0
# m個選ぶ
for m in range(k, n + 2):
    s += (m * (n - m + 1) + 1) % modulus  # 最小から最大までの個数

print(s % modulus)
N,K = map(int,input().split())
number = N+1-K+1
W = 0
for i in range(number):
    min = (K+i)*(K+i-1)/2
    max = (K+i)*(2*N-K-i+1)/2
    W += (max-min+1)
w = W % (1000000007)
print(int(w))
n,k = map(int,input().split())
mod = 10**9+7
ans = 0

for i in range(k,n+2):
  ans += (n-i+1)*i+1
  ans %= mod
  
print(ans)
n,k=map(int,input().split())
count=0
for i in range(k,n+2):
  count+=(n-i+1)*i+1
  count=count%(10**9+7)
print(count)
MOD=10**9+7
n, k = map(int, input().strip().split())
ans=0
for i in range(k,n+2):
    ans+=i*(n-i+1)+1
    ans%=MOD
print(ans)
n,k = map(int,input().split())
m=10**9+7
print(((n-k+2)*(n*(n+k+1)+2*k*(1-k)+6)//6)%m)
N, K = [int(i) for i in input().split()]
res = 0

for i in range(K, N + 2) :
	sum_lasti = i * (2 * N + 1 - i)/2 #初項 N + 1 - i 項数 i 公差1 末項 Nの等差数列の和
	sum_firsti = ( i * i - i )/ 2 #初項 0 項数 i 公差1 末項 i-1の等差数列の和
	
	res += sum_lasti - sum_firsti + 1

print(int(res%1000000007))
import math

n, k = map(int, input().split())
ary = [i for i in range(n + 1)]
# print(ary)

mod = 10 ** 9 + 7

ans = 0
min_v = sum(ary[0:(k - 1)])
max_v = sum(ary[(n + 1 - (k - 1)):])
# print(min_v, max_v)
for i in range(k, n + 2):
    min_v += ary[i - 1]
    max_v += ary[(n + 1 - i)]
    # print(min_v, max_v)
    ans = (ans + max_v - min_v + 1) % mod

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

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

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

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

    cnt+=(maxsum-minsum+1)
    cnt=cnt%mods

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

total = 0
for i in range(K, N + 2):
  maximum = (N - i + 1 + N) * i / 2
  minimum = (i - 1) * i / 2
  count = maximum - minimum + 1
  total += (count % mod)
  
print(int(total % mod))
#!/usr/bin/env python

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

    cnt = 0
    min_ = 0
    max_ = 0

    for i in range(1, n+2):
        min_ += i - 1
        max_ += n - i + 1

        if i >= k:
            cnt += max_ - min_ + 1
            cnt %= 10 ** 9 + 7

    print(cnt)


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

ans = 0
for i in range(k, n+2):
  ll = 0
  lr = i - 1
  rl = n-(i-1)
  rr = n
  lsum = lr*(lr+1)//2 - ll*(ll+1)//2
  rsum = rr*(rr+1)//2 - rl*(rl-1)//2
  ans += rsum - lsum + 1
  ans %= MOD
  #print(rsum, lsum)
  
print(ans)
N, K = map(int, input().split())

s = [0 for i in range(N+2)]
mod = 10**9+7
#s[i]:i個選んだ時の総和
for k in range(N+2):
    a = (k-1)*k/2
    b = (N+N-k+1)*k/2
    s[k] = b-a+1

#ss[i+1]:i個までの個数の総和
ss = [0 for i in range(N+2)]
for i in range(N+1):
    ss[i+1] = ss[i] + s[i] 

ans = int(ss[N+1]-ss[K]) % mod  
print(ans+1)
MOD = 10**9 + 7
N, K = [int(s) for s in input().split()]
cnt = 0
for i in range(K, N + 2):
    if i != N + 1:
        cnt += i * ((N + 1) - i) + 1
    else:
        cnt += 1
    cnt %= MOD

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

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

b = (n + 1)*(n**2 + 2*n + 6)
a = m*(2*m**2 - 3*m*(n + 2) + 3*n - 2)

ans = (a + b)//6+1
ans = ans % 1000000007
print(ans)
N,K = map(int,input().split())
A = []
c = 0

for i in range(N+2):
    A.append(i*(i-1)//2)

for i in range(K,N+2):
    c += A[N+1]-A[N-i+1]-A[i]+1
    
print(c%(10**9+7))
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))
n, k = map(int, input().split())

mod = 10**9 + 7
n_list = [0]*(n+1)
for i in range(n+1):
    n_list[i] = (10**100 + i) % mod

s = [0]*(n+1)
s[0] = n_list[0]

for i in range(1, n+1):
    s[i] = (s[i-1] + n_list[i]) % mod
#print(s)

count = 0
for i in range(k, n+1):
    min_sum = s[i-1] % mod
    max_sum = (s[n] - s[n-i]) % mod
    m = (max_sum - min_sum) + 1 % mod
    count += m
count += 1  # k=n+1の分
print(count % mod)
N, K = map(int, input().split())
ans = 1

for i in range(K, N+1):
    ans += 1/2*N*(N+1) - 1/2*(N-i)*(N-i+1) - 1/2*i*(i-1) +1
print(int(ans)%(10**9+7))
from math import factorial

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

ans = 0
j = 0
a = N + 2 - K
for i in range(0, N+1):
    n = min(N + 1 - i, a)
    ans -= i * n % M
for i in range(N, 0, -1):
    j = N - i
    n = min(N + 1 - j, a)
    ans += i * n % M
print((ans + N + 2 - K) % M)
n,k=map(int,input().split())

mod=10**9+7
ans=0
for x in range(k,n+2):
  min_a=(0+x-1)*x//2
  max_a=(n-x+1+n)*x//2
  aa=max_a-min_a+1
  ans+=aa
  
print(ans%mod)
# input
N, K = map(int, input().split())

MOD = 10**9+7

# process
def sumrange(x, y):
    ret = (x+y) * ((y-x+1)//2) 
    if (y-x+1)%2 == 1:
        ret += x+(y-x)//2
    return ret % MOD

ans = 0
for i in range(K, N+2):
    ans += sumrange(N-i+1, N) - sumrange(1, i-1) + 1
    ans %= MOD

# output
print(ans)
n,k=map(int,input().split())

al=[0]*(n+1)
bl=[0]*(n+1)
bl[0]=n
for i in range(1,n+1):
    al[i]=i+al[i-1]
    bl[i]=(n+1-i-1)+bl[i-1]
    
ans=0
for i in range(k,n+2):
    ans+=bl[i-1]-al[i-1]+1
print(ans%(10**9+7))
import itertools
n,k=map(int,input().split())
mod=10**9+7
ans=0
d=[i for i in range(n+1)]
d=list(itertools.accumulate(d))
for i in range(k,n+1):
  d_min=d[i-1]-d[0]
  d_max=d[n]-d[n-i]
  ans+=(d_max-d_min+1)
print((ans+1)%mod)
N,K=(int(x) for x in input().split())
# N,K=3,2
ans=0
for i in range(K,N+2):# i個選ぶ
    
    m=i*(i-1)/2
    M=N*(N+1)/2-(N-i)*(N-i+1)/2
    ans+=M-m+1
    # print("i,m,M",i,int(m),int(M))
print(int(ans%(1e9+7)))
import itertools

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

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

print(int(ans) % (10**9 + 7))
N, K = map(int, input().split())
MOD = 1000000007
small = 0
large = 0
res = 0

for i in range(K-1):
  small += i
  large += N-i

for i in range(K, N+2):
  small += i-1
  large += N - i +1
  gap = large - small +1
  res += gap

print(res%MOD)
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

import itertools

n, k = map(int, readline().split())
memo = [i for i in range(n + 1)]
cumsum = list(itertools.accumulate(memo))
mod = 10 ** 9 + 7
if n < k:
    print(1)
    exit()
ans = 1
for i in range(k - 1, n):
    ans += (cumsum[-1] - cumsum[n - i - 1]) - cumsum[i]
    ans += 1
    ans %= mod
print(ans % mod)
n,k = map(int, input().split())
lis = [i for i in range(n+1)]
rui = [0]*(n+2)
tmp = 0
for j in range(n+1):
    tmp += lis[j]

    rui[j+1] += tmp

ans = 0
for l in range(k,n+2):
    ans += rui[n+1]-rui[n-l+1]-rui[l] +1
ans %= 1000000007
print(ans)
N,K= map(int,input().split())
p=10**9+7
q=0
 
def calc(n,k):
  if k==1:
    return n+1
  else:
    maxi = k*n- k*(k-1)//2
    mini=  k*(k-1)//2
    #print(k,maxi,mini,maxi-mini+1)
    return maxi-mini+1
  
ans=0
for i in range(K,N+2):
  ans = ( ans+calc(N,i) )%p
  
print(ans)
import sys
input = sys.stdin.readline

mod = 10**9+7

n,k = 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 = (res+ma-mi+1)%mod

print(res)
def do(a, d, n, l):
    return (n*(a+l) // 2)

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

for i in range(k, n+2):
    #print("---")
    #print(i)
    l = do(0      , 1, i, i - 1)
    #print((0      , 1, i, i - 1))

    r = do(n+1 - i, 1, i,     n)
    #print((n+1 - i, 1, i,     n))

    #print(i, l, r, r-l+1)
    res += r-l+1
    res %= mod
print(res)
n, k = [int(i) for i in input().strip().split()]
result = 0
for i in range(k, n + 2):
    result += i * (n - i + 1) + 1
    
print(result % (10**9 + 7))
n,k = map(int, input().split())
mod = 1000000007
ans = 0
for i in range(k,n+2):
    j = i-1 
    if i == k:
        min = (j*j+j)//2 % mod
        max = sum(list(range(n,n-k,-1)))%mod
    else:
        min += j %mod
        max += (n-i+1) % mod
    ans += max - min +1
    ans %= mod
print(ans)
N,K = map(int,input().split())
MOD = 10**9+7
s = 1
for k in range(K,N+1):
    t = (N+1-k)*k+1
    # print(t)
    s += t
    s = s%MOD
print(s)
N, K = map(int, input().split())
result = 0
for i in range(K, N+2):
    mins = (i-1)/2*i
    maxs = (2*N+1-i)/2*i
    result += maxs-mins+1
print(int(result)%(10**9+7))
N,K = map(int,input().split())
ans = 0
mod = 10**9+7
for k in range(K,N+2):
    ans += (k*(N-k+1)+1)
print(ans % mod)
N, K = map(int, input().split())
MOD = 10 ** 9 + 7

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

ans = 0
for n in range(K, N + 2):
    mn = s[n-1] - s[0]
    mx = s[N] - s[max(N-n, 0)]
    count = mx - mn + 1
    ans += count
    ans %= MOD
print(ans)
N,K = map(int, input().split())

mod = pow(10,9) +7

ans = 0
for i in range(K,N+2):
    temp = (N-i+1)*i+1
    ans += temp
print(ans%mod)
import collections
import sys
input = sys.stdin.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

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

r=[]
mi=0
ma=0
su=range(n+1)
for i in range(n+1):
    mi+=su[i]
    ma+=su[::-1][i]
    r.append(ma-mi+1)

ans=0
for i in range(k-1,n+1):
    #print(r[i])
    ans+=r[i]
print(ans%(1000000007))
n,k=map(int,input().split())
mod=10**9+7
ans=0
for i in range(k,n+1):
  ans+=(n*(n+1)//2)-((n-i)*(n-i+1)//2)-(i*(i-1)//2)+1
  ans%=mod
ans+=1
ans%=mod
print(ans)
def solve(n, k):
    ans = 0
    mod = int(1e9 + 7)
    for i in range(k, n + 2):
        lb = (i - 1) * i // 2
        ub = (n + n - i + 1) * i // 2
        ans += ub - lb + 1
        ans %= mod
        # print(ub-lb+1, ub, lb, i)
    return ans


def main():
    # print(solve(3, 2))
    # print(solve(200000, 200001))
    # print(solve(141421, 35623))
    print(solve(*[int(v) for v in input().split()]))


if __name__ == '__main__':
    main()
# D - Sum of Large Numbers
from itertools import accumulate


def main():
    N, K = map(int, input().split())
    MOD = 10 ** 9 + 7
    cumsum_left = tuple(accumulate(range(N + 1)))
    cumsum_right = tuple(accumulate(range(N + 1)[::-1]))
    total = sum(r - l + 1 for l, r in zip(cumsum_left[K - 1 :], cumsum_right[K - 1 :]))
    total %= MOD
    print(total)


if __name__ == "__main__":
    main()
n,k=list(map(int,input().split()))
s=0
for i in range(k,n+2):
  s=(s+int((i*(2*n+1-i)-i*(i-1))/2+0.01)+1)%1000000007
print(s)
n,k=map(int,input().split())
p=10**9+7
def S(x):
    return (x*(x-1))//2
c=n
ans=[c+1]+[0]*n
for i in range(1,n+1):
    c=(c+(n-i))%p
    ans[i]=(c-S(i+1)+1)%p
print(sum(ans[k-1:])%p)
M=10**9 + 7
n,K=map(int, input().split())
a=n+2 - K
for k in range(K,n+2):
  a = (a + k*(n+1 - k)) % M
print(a)
MOD = int(1e9 + 7)
N, K = map(int, input().split())
ans = 0
for k in range(K, N+2):
    maximum = (N+1)*(N+2)//2 - (N+1-k)*(N+2-k)//2
    minimum = k*(k+1)//2
    ans += (maximum - minimum +1)%MOD
print(ans%MOD)