object Main {
  def main(args: Array[String]): Unit = {
    val intArray = io.StdIn.readLine().split("\n").map(_.toInt)
		val sz = intArray(0)
    var ret = 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)
	}
}