#!/bin/bash
retuInt=0
max(){
	local re;
	if (( $1>$2 )); then
		re=$1
	else
		re=$2
	fi
	retuInt=$re
	}

min(){
	local re;
	if (( $1<$2 )); then
		re=$1
	else
		re=$2
	fi
	retuInt=$re
	}
abs(){
	local re;
	if (( $1>=0 )); then
		re=$1
	else
		re=$((-$1))
	fi
	retuInt=$re
}
read -p "" n
read -p "" line
ma=0
mi=1000000001
for i in $line
do
	max $ma $i
	ma=$retuInt
	min $mi $i
	mi=$retuInt
	
done
abs $((ma-mi))
echo $retuInt