def main():

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

    mod = 10**9 + 7

    ans = 0

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

        a = N - i + 1

        ans = (ans + i * a + 1) % mod

    print(ans)



if __name__ == '__main__':

    main()

def main():

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

    mod = 10**9 + 7

    ans1 = (N + 2 - K) % mod

    ans2 = ((N + 1) * (N + 1) * (N + 2) // 2 - (N + 1) * K  * (K - 1) // 2) % mod

    ans3 = ((N + 1) * (N + 2) * (2 * N + 3) // 6 - (K - 1) * K * (2 * K - 1) // 6) % mod

    ans = (ans1 + ans2 - ans3) % mod

    print(ans)



if __name__ == '__main__':

    main()

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


if __name__ == "__main__":
    main()

def main():
    N, K = list(map(int, input().split()))
    mod = 10**9 + 7
    ans1 = (N + 2 - K) % mod
    ans2 = ((N + 1) * (N + 1) * (N + 2) // 2 - (N + 1) * K * (K - 1) // 2) % mod
    ans3 = ((N + 1) * (N + 2) * (2 * N + 3) // 6 - (K - 1) * K * (2 * K - 1) // 6) % mod
    ans = (ans1 + ans2 - ans3) % mod
    print(ans)


if __name__ == "__main__":
    main()

-    ans = 0 -    for i in range(K, N + 2): -        a = N - i + 1 -        ans = (ans + i * a + 1) % mod +    ans1 = (N + 2 - K) % mod +    ans2 = ((N + 1) * (N + 1) * (N + 2) // 2 - (N + 1) * K * (K - 1) // 2) % mod +    ans3 = ((N + 1) * (N + 2) * (2 * N + 3) // 6 - (K - 1) * K * (2 * K - 1) // 6) % mod +    ans = (ans1 + ans2 - ans3) % mod