Coins

No attempts yetTime limit1sMemory limit512 MB

Problem

Bajtazar is very proud of his collection of rare coins. He has gathered them over many years, making sure that no two are alike. He currently owns nn coins, numbered so that the ii-th coin has size exactly ii.

Because his collection has grown, Bajtazar bought a new coin album. It has exactly nn slots for coins, each with a fixed size. A coin cannot be placed in a slot that is too small for it, but it may be placed in a larger slot. Each slot holds exactly one coin, and every coin must be placed.

Bajtazar now wonders which slot to put each coin in, and in how many different ways he can fill the whole album. Because this number can be very large, it is enough to report it modulo 109+710^9 + 7. Write a program that computes this number.

Input

The first line contains one integer nn (1n1061 \le n \le 10^6). The second line contains nn integers aia_i (1ain1 \le a_i \le n) separated by single spaces. The value aia_i is the size of the largest coin that can be placed in the ii-th slot; that slot can therefore hold any coin whose size is at most aia_i.

Output

Print one integer: the number of ways to fill the album, modulo 109+710^9 + 7.