Problem:
Score : 900 points

Problem Statement

You are developing frog-shaped robots, and decided to race them against each other.

First, you placed N robots onto a number line.
These robots are numbered 1 through N.
The current coordinate of robot i is x_i.
Here, all x_i are integers, and 0 < x_1 < x_2 < ... < x_N.

You will repeatedly perform the following operation:

Select a robot on the number line. Let the coordinate of the robot be x. Select the destination coordinate, either x-1 or x-2, that is not occupied by another robot. The robot now jumps to the selected coordinate.

When the coordinate of a robot becomes 0 or less, the robot is considered finished and will be removed from the number line immediately.
You will repeat the operation until all the robots finish the race.

Depending on your choice in the operation, the N robots can finish the race in different orders.
In how many different orders can the N robots finish the race?
Find the answer modulo 10^9+7.

Constraints

2 ≤ N ≤ 10^5

x_i is an integer.

0 < x_1 < x_2 < ... < x_N ≤ 10^9

Partial Score

In a test set worth 500 points, N ≤ 8.

Input

The input is given from Standard Input in the following format:

N
x_1 x_2 ... x_N

Output

Print the number of the different orders in which the N robots can finish the race, modulo 10^9+7.

Sample Input 1

3
1 2 3

Sample Output 1

4

There are four different orders in which the three robots can finish the race:

(Robot 1 → Robot 2 → Robot 3)

(Robot 1 → Robot 3 → Robot 2)

(Robot 2 → Robot 1 → Robot 3)

(Robot 2 → Robot 3 → Robot 1)

Sample Input 2

3
2 3 4

Sample Output 2

6

There are six different orders in which the three robots can finish the race:

(Robot 1 → Robot 2 → Robot 3)

(Robot 1 → Robot 3 → Robot 2)

(Robot 2 → Robot 1 → Robot 3)

(Robot 2 → Robot 3 → Robot 1)

(Robot 3 → Robot 1 → Robot 2)

(Robot 3 → Robot 2 → Robot 1)

For example, the order (Robot 3 → Robot 2 → Robot 1) can be achieved as shown in the figure below:

Sample Input 3

8
1 2 3 5 7 11 13 17

Sample Output 3

10080

Sample Input 4

13
4 6 8 9 10 12 14 15 16 18 20 21 22

Sample Output 4

311014372

Remember to print the answer modulo 10^9+7.
This case is not included in the test set for the partial score.

Solution in Ruby (2.3.3) (judge verdict: Runtime Error)

k = gets.to_i
count = 0
s = [[]]
while(k > count)
    a = ""
    a = gets.chomp.split("").map(&:to_s)
    s[count] = a
    count = count + 1
end

black_flg = 0
memo_row = []
#全部黒の列を調べる
for r in 0..k-1
    tmp_row = []
    for c in 0..k-1
        if(s[c][r] == "#")
            black_flg = 1
            tmp_row.push(s[c][r])
        end
    end
    if(tmp_row.length == k)
        memo_row.push(r)
    end 
end

if(black_flg == 0)
    print(-1)
    exit
end
#全部黒の行を調べる
memo_col = []
for c in 0..k-1
    tmp_col = []
    for r in 0..k-1
        if(s[c][r] == "#")
            tmp_col.push(s[c][r])
        end
    end
    if(tmp_col.length == k)
        memo_col.push(c)
    end 
end

#黒があるマス目を探す
tmp_col = -1
tmp_row = -1
for r in 0..k-1
    for c in 0..k-1
        if(s[c][r] == "#")
            tmp_col = c
            tmp_row = r
            break
        end
    end
    if(tmp_col != -1)
        break
    end
end

black_row = 0
for i in 0..k-1
    if(i == tmp_row)
        next
    end
    if(s[tmp_col][i] == "#")
        black_row += 1
    end
end

if(memo_col.length > 0) 
    print(k - memo_row.length)
    exit
end

#いったん塗る
for i in 0..k-1
    s[tmp_col][i] = "#"
end

memo_row2 = []
#全部黒の列を調べる
for r in 0..k-1
    tmp_row = []
    for c in 0..k-1
        if(s[c][r] == "#")
            tmp_row.push(s[c][r])
        end
    end
    if(tmp_row.length == k)
        memo_row2.push(r)
    end 
end

#全部黒の列分はひく。
result = k + k - 1 - black_row - memo_row.length - memo_row2.length
print(result)