import scala.io.Source
import scala.annotation.tailrec

object Main{
  def main(args: Array[String]){
    val lines = for{
      in <- Source.stdin.getLines.toVector
    }yield in.toInt

    println(rec(lines.tail, Int.MinValue))
  }

  @tailrec
  def rec(vec: Vector[Int], max: Int): Int ={
    if(vec.init.isEmpty) max
    else rec(vec.init, Math.max(vec.last - vec.init.min, max))
  }
}