object Main extends App {
  import scala.io.StdIn._

  val n = readInt
  implicit val task = readLine.trim.split(' ').map(_.toInt).toList
  println(
    lowerBound(0, 100)(canMake) - 1
  )
  def canMake(norma: Int)(implicit task: List[Int]): Boolean = {
    def sub(restTask: List[Int], stocked: Int = 0): Boolean = {
      restTask match {
        case Nil ⇒ true
        case h::t if stocked + h >= norma ⇒ sub(t, stocked + h - norma)
        case _ ⇒ false
      }
    }
    sub(task)
  }
  def lowerBound(from: Int, until: Int)(func: Int => Boolean) : Int = {
    var left = from
    var right = until
    while(left < right){
      val mid = (left + right) / 2
      if (func(mid)){
        left = mid + 1
      }else {
        right = mid
      }
    }
    right
  }
  implicit class Scope[T](val value: T) extends AnyVal {
    @inline
    def let[A](func: T ⇒ A): A = func(value)
  }
}
