import Foundation
let N=Int(readLine()!)!
var strA=readLine()!.componentsSeparatedByString(" ")
var A=[Int]()
for i in strA{
  A.append(Int(i)!)
}
let max=A.maxElement()
let min=A.minElement()
print(max!-min!)