#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
using namespace std;
signed main(){
	int n;
	cin >> n;
	vec(a,n);
	REP(i,n){
		cin >> a[i];
	}
	sort(a.bebin(),a.end());
	cout << a[n-1]-a[0] << endl;
    return 0;
}