import scala.io.StdIn

object Main {
  def main(args: Array[String]){
    val n = StdIn.readInt()
    var res = Int.MinValue
    var list = scala.collection.mutable.ListBuffer.empty[Int]

    for(i <- 0 to n - 1){
      list += StdIn.readInt()
    }
    for(i <- 0 to n - 1){
      for(j <- i + 1 to n - 1){
        res = List(res,list(j) - list(i)).max
      }
    }
    println(res)
  }
}