fun f(x: Int, m: Long): Long = if (x > 0) 1L * x * f(x - 1, m) % m else 1L

fun main(args: Array<String>) {
  val MOD = (1e9 + 7).toLong()
  val n = readLine()!!.toInt()
  val x = readLine()!!.split(" ").map { it.toLong() }
  var ans = 1L
  var l = 0
  for (r in 1..n) {
    if (x[r - 1] >= 2 * (r - l) - 1) continue
    ans *= r - l
    ans %= MOD
    l++
  }
  println(ans * f(n - l, MOD) % MOD)
}
