#include<cstdio>
using namespace std;
int maxx=0,minn=2e9,N;
int main()
{
	scanf("%d",&N);
	for(int i=1,a;i<=N;i++)
	{
		scanf("%d",&a);
		if(a<minn)
		minn=a;
		if(a>maxx)
		maxx=a;
	}
	printf("%d",maxx-minn);
	return 0;
}