import java.util.Scanner

object Main extends App {

  val sc = new Scanner(System.in)

  def nextInt() = sc.next.toInt

  val n = nextInt
  val rs = List.fill(n)(nextInt)

  val xs = rs.zipWithIndex
  val descending = xs sortWith (_._1 > _._1)
  val ascending = xs sortWith (_._1 < _._1)

  def maxProfit(): Option[Int] = {

    def loop1(as: List[(Int, Int)], max: Option[Int]): Option[Int] = {
      if (as.isEmpty)
        max
      else if (max.isDefined && descending(0)._1 - as.head._1 <= max.get)
        max
      else {
        val max2 = loop2(as.head, descending)
        loop1(
          as.tail,
          if (max.isDefined && max2.isDefined)
            Some(max.get max max2.get)
          else if (max.isDefined)
            max
          else if (max2.isDefined)
            max2
          else
            None
        )
      }
    }

    def loop2(a: (Int, Int), ds: List[(Int, Int)]): Option[Int] = {
      ds match {
        case List() => None
        case d :: ds1 =>
          if (d._2 > a._2) Some(d._1 - a._1)
          else loop2(a, ds1)
      }
    }
    loop1(ascending, None)
  }

  println(maxProfit.getOrElse("None"))
}

