object Main {
  def main(args: Array[String]): Unit = {
    val inputString = io.StdIn.readLine()
    val intArray = inputString.split("\n").map(_.toInt)
    val sz = intArray(0)
    var ret = 0 // Int.MinValue
    for(i <- 1 to sz) {
      for(j <- i+1 to sz) {
        val temp = intArray(j) - intArray(i)
        if(temp>ret) ret = temp
      }
    }
    println(ret)
  }
}