Valera learned another connector smoke, but out of habit, he threw a molotov at his teammates' feet instead. Now, to get invited to FaceIt again, he needs to solve the problem of a person who plays CS2 on macOS. However, he needs to keep learning smokes, so he asked you to help him with the problem.
Given an array of length . You need to find the number of ways to split it into contiguous subarrays such that the of the -th subarray is equal to i−1. Here is in -indexation. Because of the loss of Problem Setter's favorite CS2 team, he asks you to calculate this modulo 10^9+7.
The mex (minimum excluded value) of a set of non-negative integers is the smallest non-negative integer that is not present in the set. The mex of \{1,0,2,4\} is . The mex of \{1,2,3\} is . The mex of \{0,2,3\} is .
The first line contains one integer (1 \leq n \leq 2 \cdot 10^5) — the size of array .
The second line contains integers a_i (0 \leq a_i < n) representing the elements of the array .
For each test case, output a single integer — the number of ways to split the array into contiguous subarrays such that the condition described in the statement is satisfied, modulo 10^9 + 7.
Example 1
( points): n \le 20
( points): n \le 100;
( points): n \le 500;
( points): n \le 800;
( points): n \le 5\cdot10^4;
( points): n \le 10^5;
( points): no additional constraints