#include <iostream>
using namespace std;
int N,a,mi = 1e9,ma = 0;
int main(){
	cin >> N;
  	for(int i=0;i<N;i++){
		cin >> a;
      	mi = min(a,mi);
      	ma = max(a,ma);
    }
  	cout << ma-mi << endl;
}