This page is still under construction.

Parts of this page are still being built. What you see may change.

Infectious Disease

Time limit5sMemory limit1024 MB

Summary
Find the expected number of days until a random infection and vaccine-persuasion process ends in a city of n people, modulo 1e9+7.
Level

Hard9 of 10

Topics
Probability, Math, Dynamic programming
Solved
No attempts yet

Problem

In the year 2202, a strange disease begins to spread in a city of nn people. To stop the spread, experts invented a strong vaccine called Mysterious Oscar. On day 00, one citizen is infected and another citizen is vaccinated. A vaccinated person is cured immediately and can neither catch nor spread the disease. On each later day dd (d>0d>0), every citizen who was infected strictly before day dd chooses one uninfected and unvaccinated citizen with equal probability and infects that citizen. If an infected citizen has no uninfected and unvaccinated citizen left to choose, that citizen does nothing. After the infection step, every citizen who was vaccinated strictly before day dd chooses 2 different unvaccinated citizens with equal probability and persuades them to take the vaccine, one by one. If a vaccinated citizen has fewer than 2 unvaccinated citizens to choose from, that citizen persuades all the remaining unvaccinated citizens. Grammy wants to know how many days pass before the disease is fully extinguished. Find the expected number of days until all patients are cured.

Output

It can be shown that the answer is an irreducible fraction xy\frac{x}{y}, where xx and yy are integers and y≢0(mod109+7)y \not\equiv 0 \pmod{10^9+7}. Output the integer x⋅y−1(mod109+7)x\cdot y^{-1}\pmod{10^9+7}. In other words, output the integer aa with 0≤a<109+70\leq a<10^9+7 and a⋅y≡x(mod109+7)a\cdot y\equiv x\pmod{10^9+7}.

Input

The only line contains an integer nn (2≤n≤1.4⋅1072 \leq n \leq 1.4 \cdot 10^7), the population of the city.

Output format

Output a single integer, the expected number of days before all patients are cured, modulo 109+710^9+7.

Examples2

  1. Example 1

    Input
    2
    
    Expected output
    1
    
  2. Example 2

    Input
    114
    
    Expected output
    505208013