object Main {
  def main(args: Array[String]): Unit = {
    val n = readLine.toInt
    val input = (1 to n map { _ => readLine.toInt }).toList
    // println(input)
    println(calMaxProf(input))
  }

  @tailrec def calMaxProf(input: List[Int], maxProf: Int = Int.MinValue): Int = input match {
    case head :: Nil =>
      maxProf
    case head :: tail =>
      val prof = tail.map(_ - head).max
      if (prof > maxProf) {
        calMaxProf(tail, prof)
      } else {
        calMaxProf(tail, maxProf)
      }
    case Nil =>
      maxProf
  }
}

