local mod = 1000000007
local n = io.read("*n")
local t = {}
for i = 1, n do
  t[i] = io.read("*n")
end
local currank = 1
local currank_left = 1
local tgt = -1
local rank = {}
for i = 1, n do rank[i] = 0 end
for i = 1, n do
  if t[i] < tgt + 2 then
    local currank_right = i
    rank[currank] = currank_right - currank_left + 1
    currank = currank + 1
    currank_left = i + 1
  else
    tgt = tgt + 2
  end
end
if currank_left <= n then
  rank[currank] = n + 1 - currank_left
end
for i = 2, #rank do
  rank[i] = rank[i] + rank[i - 1]
end
local ret = 1
for i = 1, n do
  ret = (ret * (rank[i] + 1 - i)) % mod
end
print(ret)
