#include<iostream>
using namespace std;

int n, max, min, a;

int main() {
	cin >> n;
	max = -9999999;
	min = 99999999;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a > max)max = a;
		if (a < min)min = a;
	}
	cout << max - min << endl;
	return 0;
}