object Main {
  def main(args: Array[String]): Unit = {
    val rs = io.Source.stdin
      .getLines()
      .toStream
      .filter(_.matches("\\d+"))
      .map(_.trim.toInt)
      .tail
      .toList

    val minRs = rs.scan(rs.head)(_ min _).drop(1)
    val maxRs = (rs.tail, minRs.init).zipped.map(_ - _)
    println(maxRs.max)
  }
}

