mod = 10 ** 9 + 7



N, *X = list(map(int, open(0).read().split()))



stack = []

ans = 1

for x in X:

    stack.append(x)

    if x < 2 * len(stack) - 1:

        ans = (ans * len(stack)) % mod

        stack.pop()

    else:

        ans = (ans * len(stack)) % mod



print(ans)

mod = 10 ** 9 + 7



N, *X = list(map(int, open(0).read().split()))



s = 0

ans = 1

for x in X:

    if x < 2 * s + 1:

        ans *= (s + 1)

    else:

        s += 1

        ans *= s

    ans %= mod



print(ans)
mod = 10**9 + 7
N, *X = list(map(int, open(0).read().split()))
stack = []
ans = 1
for x in X:
    stack.append(x)
    if x < 2 * len(stack) - 1:
        ans = (ans * len(stack)) % mod
        stack.pop()
    else:
        ans = (ans * len(stack)) % mod
print(ans)

mod = 10**9 + 7
N, *X = list(map(int, open(0).read().split()))
s = 0
ans = 1
for x in X:
    if x < 2 * s + 1:
        ans *= s + 1
    else:
        s += 1
        ans *= s
    ans %= mod
print(ans)

-stack = [] +s = 0 -    stack.append(x) -    if x < 2 * len(stack) - 1: -        ans = (ans * len(stack)) % mod -        stack.pop() +    if x < 2 * s + 1: +        ans *= s + 1 -        ans = (ans * len(stack)) % mod +        s += 1 +        ans *= s +    ans %= mod