import scala.io.StdIn

object Main {

  def main(args: Array[String]): Unit = {
    val rownum = StdIn.readInt

    var maxv = -2000000000
    var minv = StdIn.readInt

    for (i <- 2 to rownum) {
      val c = StdIn.readInt
      if (maxv < c - minv) maxv = c - minv
      if (c < minv) minv = c
    }

    print(maxv)

  }
}