Under construction

Still being built. Things may change

The Lucky Letter

Time limit2sMemory limit512 MB

Summary
Find the smallest positive n whose remainder modulo every a from 2 to m equals a-1, that is, n ≡ -1 mod each a.
Level

Medium4 of 10

Topics
Number theory, Math
Solved
No attempts yet

Problem

Jigui got this letter one day.

This letter began in England, travelled around the world once a year, and brought luck to everyone who received it. Now it has reached you. You must solve the problem below within 12 hours and send seven copies of this letter, this one included, to people who need luck. Copying is allowed. (...) The number written on this letter is mm. Find the smallest positive integer nn such that n≡a−1(moda)n \equiv a-1 \pmod{a} for every natural number aa with 2≤a≤m2 \le a \le m.

Jigui read the letter all the way to the end by accident and has felt uneasy ever since, because the problem is still unsolved. Solve it for Jigui.

Put another way, find the smallest positive integer nn whose remainder on division by aa equals a−1a-1 for every integer aa with 2≤a≤m2 \le a \le m.

Input

The first line contains the integer mm written on the letter. (2≤m≤10002 \le m \le 1000)

Output

Print the smallest positive integer nn that satisfies the condition. When mm is 10001000, nn has 433433 digits, so it does not fit in a 64-bit integer type.

Examples4

  1. Example 1

    Input
    2
    
    Expected output
    1
    
  2. Example 2

    Input
    3
    
    Expected output
    5
    
  3. Example 3

    Input
    4
    
    Expected output
    11
    
  4. Example 4

    Input
    5
    
    Expected output
    59