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

#GL0000207. Nghịch đảo tổng các ước (Alternate Task)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Nghịch đảo tổng các ước (Alternate Task)

Nghịch đảo tổng các ước (Alternate Task)

Source: UVa

Version: Phuoc Hung OJ Extended

Problem Statement

Let σ(x)\sigma(x) be the sum of all positive divisors of xx, including 11 and xx. Given SS, find the largest positive integer xx such that σ(x)=S\sigma(x)=S. Print −1-1 if none exists.

Input

One line with SS.

Output

Print the largest xx or −1-1.

Subtasks

  • Subtask 1 (20 points): 1≤S≤1001\le S\le 100.

  • Subtask 2 (30 points): 1≤S≤5001\le S\le 500.

  • Subtask 3 (50 points): 1≤S≤10001\le S\le 1000.

Examples

Example 1

Input

1

Output

1

Explanation

The only positive divisor of 1 is 1.

Example 2

Input

102

Output

101

Explanation

101 is prime and its divisor sum is 102. No larger integer can have that divisor sum.

Example 3

Input

1000

Output

-1

Explanation

No positive integer has divisor sum equal to 1000.