PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000253. Madoka và Trường Đại học Tốt Nhất (Madoka and The Best University)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Madoka và Trường Đại học Tốt Nhất (Madoka and The Best University)

Madoka and The Best University

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Madoka wants to study at Novosibirsk State University. During the entrance examination, she encounters a task involving three positive integers.

Given an integer nn, consider every ordered triple (a,b,c)(a,b,c) of positive integers satisfying

a+b+c=n.a+b+c=n.

For each triple, first compute the greatest common divisor of aa and bb, then compute the least common multiple of that value and cc. Its contribution is

lcm⁡(c,gcd⁡(a,b)).\operatorname{lcm}\bigl(c,\gcd(a,b)\bigr).

Here gcd⁡(x,y)\gcd(x,y) is the greatest common divisor, and lcm⁡(x,y)\operatorname{lcm}(x,y) is the least common multiple of two positive integers x,yx,y.

Calculate the sum of these contributions over all valid triples (a,b,c)(a,b,c). Distinct triples are counted separately even when they contain the same values in different orders.

Input

  • The only line contains an integer nn, the required sum of the three values in each triple.

Output

  • Print one integer: the required sum modulo 109+710^9+7.

Subtasks

  • Subtask 1 (20 points): 3≤n≤1203\le n\le 120.
  • Subtask 2 (30 points): 3≤n≤50003\le n\le 5000.
  • Subtask 3 (50 points): 3≤n≤1000003\le n\le 100000.

Examples

Example 1

Input

3

Output

1

Explanation

The only positive triple summing to 33 is (1,1,1)(1,1,1). Its greatest common divisor is gcd⁡(1,1)=1\gcd(1,1)=1; hence its contribution is lcm⁡(1,1)=1\operatorname{lcm}(1,1)=1. The answer is 11.

Example 2

Input

5

Output

11

Explanation

There are exactly six ordered triples of positive integers with sum 55:

  • (1,1,3)(1,1,3): gcd⁡(1,1)=1\gcd(1,1)=1, hence lcm⁡(3,1)=3\operatorname{lcm}(3,1)=3.
  • (1,2,2)(1,2,2): gcd⁡(1,2)=1\gcd(1,2)=1, hence lcm⁡(2,1)=2\operatorname{lcm}(2,1)=2.
  • (2,1,2)(2,1,2): gcd⁡(2,1)=1\gcd(2,1)=1, hence lcm⁡(2,1)=2\operatorname{lcm}(2,1)=2.
  • (1,3,1)(1,3,1): gcd⁡(1,3)=1\gcd(1,3)=1, hence lcm⁡(1,1)=1\operatorname{lcm}(1,1)=1.
  • (3,1,1)(3,1,1): gcd⁡(3,1)=1\gcd(3,1)=1, hence lcm⁡(1,1)=1\operatorname{lcm}(1,1)=1.
  • (2,2,1)(2,2,1): gcd⁡(2,2)=2\gcd(2,2)=2, hence lcm⁡(1,2)=2\operatorname{lcm}(1,2)=2.

Their contributions sum to 3+2+2+1+1+2=113+2+2+1+1+2=11. Because this is less than 109+710^9+7, the printed remainder is also 1111.

Example 3

Input

69228

Output

778304278

Explanation

Here n=69228n=69228. Every ordered positive triple (a,b,c)(a,b,c) whose entries sum to 6922869228 contributes exactly one value lcm⁡(c,gcd⁡(a,b))\operatorname{lcm}(c,\gcd(a,b)). Summing all contributions and taking the remainder modulo 109+710^9+7 gives 778304278778304278. Neither the individual triples nor the unreduced total are printed.