#include<iostream>
#include<algorithm>
using namespace std;

int main(){
	int N,a;
  	cin>>N;
  	cin>>a;
  	maxv=a;minv=a;
  	for(int i=1;i<N;++i){
    	cin>>a;
      	maxv=max(a,maxv);
      	minv=min(a,minv);
    }
  	cout<<maxv-minv<<endl;
  	return 0;

}