#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<set>
using namespace std;
int n,maxn,minn=1e9+5,k;
int main(){
	scanf("%d",&n);
	while(n--){
		scanf("%d",&k);
		maxn=max(maxn,k);
		minn=min(minn,k);
	}
	printf("%d",maxn-minn);
	return 0;
} 