inp_str = input()
N, K = list(map(func, inp_str.split(" ")))

def choise(n, m):
    if n == 0:
        return 0
    min_sum = (0 + m - 1) * m // 2 % MOD
    max_sum = (2*n - m + 1) * m // 2 % MOD
    return max_sum - min_sum + 1
ans_list = [choise(N, m) for m in range(1, N+2)]
sum_ans = 0
for ans in ans_list[K-1:]:
    sum_ans += ans
    sum_ans = sum_ans % MOD
print(int(sum_ans))