Dnipro Conquers Space#4548

Dnipro Conquers Space

1 second
64 megabytes
Medium

Everyone knows that Dnipropetrovsk is the space capital of Ukraine. The Southern Machine-Building Plant produces launch vehicles, engines, and other space exploration devices that are recognized worldwide. For instance, the American Antares launch vehicle was recently launched using engines made at the Yuzhnoye Design Bureau. Dnipropetrovsk's contributions to space exploration continue to grow.

A critical task for spacecraft is maintaining communication with Earth. To model this process, a permutation of natural numbers from to is sent to a computer. However, errors can occur during data transmission, so instead of a specific number , the numbers a-1, , or a+1 might be received. Our goal is to reconstruct the original permutation from the received data. Unfortunately, it's not always possible to do this uniquely. Your challenge, as a participant in the traditional All-Ukrainian competition "Peaceful Space," is to determine how many different permutations could have resulted from the received data set.

Input

The first line contains the number (1 \le n \le 10^5). The second line contains numbers, each ranging from to n+1.

Output

Output a single number — the answer to the problem. Since the result can be very large, provide it modulo (10^9+7).

Examples

Example 1

Loading
Loading