object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val _ = readLine
    val iobuf = readLine.split(" ").map(_.toInt).sorted
    val ans = iobuf.last - iobuf.head
    println(ans)
  }
}
