Under construction

Still being built. Things may change

Computing a Well-Known Sum

Time limit1sMemory limit1024 MB

Summary
Sum f(i)*g(i) for i from 1 to N, where f(i)=N div i and g(i)=i mod M, with N and M up to 1e9, modulo 1e9+7.
Level

Hard8 of 10

Topics
Math, Number theory, Divide and conquer, Implementation
Solved
No attempts yet

Problem

Define f(x)f(x) as the quotient when NN is divided by xx, and g(x)g(x) as the remainder when xx is divided by MM.

Find the remainder of the following value modulo 1 000 000 0071\,000\,000\,007.

∑i=1Nf(i)×g(i)\sum_{i=1}^N f(i)×g(i)

Input

The first line contains integers NN and MM, separated by a space. (1≤N,M≤1091 \le N, M \le 10^9)

Output

Print the value of the given expression modulo 1 000 000 0071\,000\,000\,007.

Examples1

  1. Example 1

    Input
    4 3
    
    Expected output
    9