object Main extends App {
  val n = readInt
  val source: Seq[Int] = Stream.continually(readInt).take(n)

  def loop(prices: Seq[Int]): Seq[Int] = {
    if (prices.size == 1) Nil
    else {
      val base = prices.head
      prices.tail.map(_ - base) ++ loop(prices.tail)
    }
  }

  println(loop(source).max)
}

