
object Main extends App {

  import scala.io.StdIn._
  import scala.math._


  //X == 1 だけ例外
  val n = readLine.trim.toInt
  val strs = readLine.trim.split(' ').map(_.toInt)
  if ((1 until strs.length).forall(it ⇒ strs(it) > strs(it - 1))){
    println(1)
  }else {
    val list = strs.toList
    val head = strs(0)
    var left = 2
    var right = n
    while (left < right){
      val mid = (left + right) / 2
      if (canMake(list.tail, mid, List(new CharWithLength(1, head)), head)) {
        right = mid
      }else {
        left = mid + 1
      }
    }
    println(right)
  }
  def canMake(strs: List[Int], x: Int, current: List[CharWithLength], currentLength: Int): Boolean = {

    strs match {
      case str::r if str == currentLength ⇒
        countUp(current, x) match {
          case Some(next) ⇒ canMake(r, x, next, currentLength)
          case None ⇒ false
        }
      case str::r if str > currentLength ⇒ canMake(r, x, new CharWithLength(1, str - currentLength)::current, str)
      case str::r ⇒ countUp(shrink(current, currentLength - str), x) match {
        case Some(next) ⇒ canMake(r, x, next, str)
        case None ⇒ false
      }
      case Nil ⇒ true
    }
  }
  def shrink(current: List[CharWithLength], remove: Int): List[CharWithLength] = {
    current match {
      case h::t if h.length > remove ⇒ new CharWithLength(h.rank, h.length - remove)::t
      case h::t if h.length == remove ⇒ t
      case h::t ⇒ shrink(t, remove - h.length)
    }
  }
  def countUp(current: List[CharWithLength], x: Int): Option[List[CharWithLength]] = {
    current match {
      case h::Nil if h.rank == x ⇒ None
      case h::t if h.rank == x ⇒ countUp(t, x) match {
        case Some(upped) ⇒ Some(new CharWithLength(1, h.length)::upped)
        case None ⇒ ???
      }
      case h::i::t if h.length == 1 && h.rank + 1 == i.rank ⇒ Some(new CharWithLength(i.rank, i.length + 1)::t)
      case h::t if h.length == 1 ⇒ Some(new CharWithLength(h.rank + 1, 1)::t)
      case h::t ⇒ Some(new CharWithLength(h.rank + 1, 1)::new CharWithLength(h.rank, h.length - 1)::t)
    }

  }
  def exponent(base: Int, exp: Int): Long = {
    exp match {
      case 0 ⇒ 1L
      case 1 ⇒ base
      case _ ⇒ exponent(base, exp / 2).let{it ⇒ it * it * exponent(base, exp % 2)}
    }
  }

  class CharWithLength(val rank: Int, var length: Int) {
    override def toString: String = rank.toString * length
  }
  implicit class Extenion[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}