import scala.io.Source.stdin

object Main {
  def main(args: Array[String]) = {
    val list = stdin.getLines().buffered.map { _.toInt }
    val n = list.next()
    val r0 = list.next()
    val r1 = list.next()
    var max = r1 - r0
    var min = if(r0 > r1) r1 else r0
    for( m <- list ) {
      if( max < m - min) {
        max = m - min
        if( min -m > 0 )
          min = m
      }
      else if( min - m > 0 ) {
        min = m
      }
    }
    println(max)
  }
}