import scala.io.Source

object Main{
  def main(args: Array[String]){
    val lines = for{
      in <- Source.stdin.getLines.toList
    }yield in.toInt

    println(rec(lines.tail).max)
  }

  def rec(list: List[Int]): List[Int] =
    if(list.length == 1) Nil
    else maxDiff(list.init, list.last) :: rec(list.init)

  def maxDiff(list: List[Int], n: Int): Int = list.map(n - _).max
}