package main

import "fmt"
import "sort"

func main() {
    var N, v, d int
    var list []int

    fmt.Scanf("%d", &N)

    for i := 0; i < N; i++ {
        fmt.Scanf("%d", &v)
        list = append(list, v)
    }
    sort.Sort(sort.IntSlice(list))

    for i := 1; i < N; i++ {
        d += (list[i] - list[i-1])
    }
    fmt.Println("%d", d)
}