n = eval(input())

x = list(map(int, input().split()))



MOD = 1000000007



j = 1

ans = 1

count = 0

for i in range(len(x)):

    if(x[i] >= 2*j-1):

        j += 1

        continue

    else:

        ans *= j

        count += 1



for i in range(len(x)-count):

    ans = ans*(i+1)%MOD



print(ans)
n = eval(input())

x = list(map(int, input().split()))



MOD = 10**9+7



j = 1

ans = 1

count = 0

for i in range(len(x)):

    if(x[i] >= 2*j-1):

        j += 1

        continue

    else:

        ans = ans*j%MOD

        count += 1



for i in range(len(x)-count):

    ans = ans*(i+1)%MOD



print(ans)
n = eval(input())
x = list(map(int, input().split()))
MOD = 1000000007
j = 1
ans = 1
count = 0
for i in range(len(x)):
    if x[i] >= 2 * j - 1:
        j += 1
        continue
    else:
        ans *= j
        count += 1
for i in range(len(x) - count):
    ans = ans * (i + 1) % MOD
print(ans)

n = eval(input())
x = list(map(int, input().split()))
MOD = 10**9 + 7
j = 1
ans = 1
count = 0
for i in range(len(x)):
    if x[i] >= 2 * j - 1:
        j += 1
        continue
    else:
        ans = ans * j % MOD
        count += 1
for i in range(len(x) - count):
    ans = ans * (i + 1) % MOD
print(ans)

-MOD = 1000000007 +MOD = 10**9 + 7 -        ans *= j +        ans = ans * j % MOD