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