CF380D.Sereja and Cinema

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

The cinema theater hall in Sereja's city is nn seats lined up in front of one large screen. There are slots for personal possessions to the left and to the right of each seat. Any two adjacent seats have exactly one shared slot. The figure below shows the arrangement of seats and slots for n=4n=4 .

Today it's the premiere of a movie called "Dry Hard". The tickets for all the seats have been sold. There is a very strict controller at the entrance to the theater, so all nn people will come into the hall one by one. As soon as a person enters a cinema hall, he immediately (momentarily) takes his seat and occupies all empty slots to the left and to the right from him. If there are no empty slots, the man gets really upset and leaves.

People are not very constant, so it's hard to predict the order in which the viewers will enter the hall. For some seats, Sereja knows the number of the viewer (his number in the entering queue of the viewers) that will come and take this seat. For others, it can be any order.

Being a programmer and a mathematician, Sereja wonders: how many ways are there for the people to enter the hall, such that nobody gets upset? As the number can be quite large, print it modulo 10000000071000000007 (109+7)(10^{9}+7) .

输入格式

The first line contains integer nn (1<=n<=105)(1<=n<=10^{5}) . The second line contains nn integers, the ii -th integer shows either the index of the person (index in the entering queue) with the ticket for the ii -th seat or a 00 , if his index is not known. It is guaranteed that all positive numbers in the second line are distinct.

You can assume that the index of the person who enters the cinema hall is a unique integer from 1 to nn . The person who has index 1 comes first to the hall, the person who has index 2 comes second and so on.

输出格式

In a single line print the remainder after dividing the answer by number 10000000071000000007 (109+7)(10^{9}+7) .

输入输出样例

  • 输入#1

    11
    0 0 0 0 0 0 0 0 0 0 0
    

    输出#1

    1024
    
  • 输入#2

    6
    0 3 1 0 0 0
    

    输出#2

    3
    
首页