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

#GL0000269. Tổng tích với ước chung lớn nhất (GCD Product Sum)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Tổng tích với ước chung lớn nhất (GCD Product Sum)

GCD Product Sum

Source: SPOJ

Version: Phuoc Hung OJ Extended

Problem Statement

Given a positive integer nn, compute S(n)=∑i=1nigcd⁡(i,n)S(n)=\sum_{i=1}^{n}i\gcd(i,n), where gcd⁡(i,n)\gcd(i,n) is the greatest common divisor.

Input

Read one integer nn.

Output

Print the exact integer S(n)S(n) without applying a modulus.

Subtasks

  • Subtask 1 (20 points): 1≤n≤1001\le n\le 100.
  • Subtask 2 (30 points): 1≤n≤100001\le n\le 10000.
  • Subtask 3 (50 points): 1≤n≤10000001\le n\le 1000000.

Examples

Example 1

Input

4

Output

24

Explanation

For n=4n=4, the required sum is 1⋅1+2⋅2+3⋅1+4⋅4=241\cdot1+2\cdot2+3\cdot1+4\cdot4=24.

Example 2

Input

6

Output

63

Explanation

For n=6n=6, the required sum is 1⋅1+2⋅2+3⋅3+4⋅2+5⋅1+6⋅6=631\cdot1+2\cdot2+3\cdot3+4\cdot2+5\cdot1+6\cdot6=63.

Example 3

Input

7

Output

70

Explanation

For n=7n=7, the required sum is $1\cdot1+2\cdot1+3\cdot1+4\cdot1+5\cdot1+6\cdot1+7\cdot7=70$.

Example 4

Input

9

Output

135

Explanation

For n=9n=9, the required sum is $1\cdot1+2\cdot1+3\cdot3+4\cdot1+5\cdot1+6\cdot3+7\cdot1+8\cdot1+9\cdot9=135$.