import scala.io.StdIn.{readLong, readInt}

object Main extends App {

  val n  = readInt()
  val a  = readLong()
  val b  = readLong()
  val xs = Iterator.fill(n - 2)(readLong())

  val (max, _) = xs.foldLeft((b - a, math.min(a, b))) {
    case ((maxDiff, min), x) => (math.max(maxDiff, x - min), math.min(min, x))
  }
  println(max)
}

