GCD Extreme II#1229

GCD Extreme II

1 second
128 megabytes
Very easy

For a given calculate the value of , where

G = \sum_{i=1}^{n-1} \sum_{j=i+1}^{n} GCD(i,j)

Here GCD(i, j) means the greatest common divisor of integers and .

For those who have trouble understanding summation notation, the meaning of is given in the following code:

g = 0;
for (i = 1; i < n; i++)
for (j = i + 1; j <= n; j++)
  g += gcd(i, j);

Input

Consists of no more than lines. Each line contains one integer (1 < n \le 4 \cdot 10^6). Input is terminated by a line containing a single zero and should not be processed.

Output

For each input number print in a separate line the corresponding value of . The value of fits in a -bit signed integer.

Examples

Example 1

Loading
Loading