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

#GL0000179. Tổng các ước thực sự (Divisor Summation)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Tổng các ước thực sự (Divisor Summation)

Divisor Summation

Source: SPOJ

Version: Phuoc Hung OJ Extended

Problem Statement

A positive integer dd is a proper divisor of a positive integer nn when n mod d=0n\bmod d=0 and d<nd<n.

For example, the proper divisors of 2020 are 1,2,4,5,101,2,4,5,10, whose sum is 2222. The number 2020 itself is excluded.

Given a positive integer nn, print the sum of all its proper divisors. The sum is 00 when there are no proper divisors.

Input

One line containing the integer nn.

Output

Print one integer: the sum of the proper divisors of nn.

Subtasks

  • Subtask 1 (20 points): 1≤n≤1001 \le n \le 100.
  • Subtask 2 (30 points): 1≤n≤1041 \le n \le 10^4.
  • Subtask 3 (50 points): 1≤n≤5000001 \le n \le 500000.

Examples

Example 1

Input

20

Output

22

Explanation

The positive divisors are 1,2,4,5,10,201,2,4,5,10,20. Exclude 2020 and add the rest to obtain 2222.

Example 2

Input

1

Output

0

Explanation

11 has no positive divisor strictly smaller than itself, so the sum is 00.