import java.util.Scanner

object Main extends App {

  val sc = new Scanner(System.in)

  def nextInt() = sc.next.toInt

  def maxProfit(n: Int, maxv: Int, minv: Int): Int = {
    if (n == 0)
      maxv
    else {
      val r = nextInt
      maxProfit(n - 1, maxv max (r - minv), minv min r)
    }
  }

  val n = nextInt
  val r0 = nextInt
  val r1 = nextInt

  println(maxProfit(n - 2, r1 - r0, r0 min r1))
}

