// 7/4 Tuesday
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int n,ans;
	cin >> n;
	vector <int> A(n);
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}

	sort(A.begin(), A.end());
	ans = A.begin - A.end;
	cout << ans << endl;
	return 0;
}