package main

import (
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	var n int
	_, err := fmt.Fscanf(os.Stdin, "%d", &n)
	if err != nil {
		panic(err)
	}

	var input string
	_, err = fmt.Fscanf(os.Stdin, "%s", &input)
	if err != nil {
		panic(err)
	}

	nums := strings.Split(input, " ")

	min, max := 1001, -1
	for _, v := range nums {
		tmp, _ := strconv.Atoi(v)
		if min > tmp {
			min = tmp
		}
		if max < tmp {
			max = tmp
		}
	}

	fmt.Println(max - min)
}
