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

#SP0000094. Dãy tổng các ước thực sự (Amazing Factor Sequence)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Dãy tổng các ước thực sự (Amazing Factor Sequence)

Amazing Factor Sequence

Source: SPOJ

Version: Phuoc Hung OJ Extended

Problem Statement

Define a0=a1=0a_0=a_1=0. For each n>1n>1, let f(n)f(n) be the sum of all proper positive divisors of nn, i.e. positive divisors dd with d<nd<n. Define an=an−1+f(n)a_n=a_{n-1}+f(n). Given NN, compute aNa_N. For example, f(4)=1+2=3f(4)=1+2=3 and f(5)=1f(5)=1.

Input

One line contains the positive integer NN.

Output

Print the integer aNa_N.

Subtasks

  • Subtask 1 (20 points): 2≤N≤10002\le N\le 1000.
  • Subtask 2 (30 points): 2≤N≤1000002\le N\le 100000.
  • Subtask 3 (50 points): 2≤N≤9999992\le N\le 999999.

Examples

Input

5

Output

6

Explanation

We have f(2)=1f(2)=1, f(3)=1f(3)=1, f(4)=1+2=3f(4)=1+2=3, and f(5)=1f(5)=1. Starting with a1=0a_1=0, the running totals are a2=1a_2=1, a3=2a_3=2, a4=5a_4=5, and a5=6a_5=6. Print 6.