#include <bits/stdc++.h>
using namespace std;
long long n, a, maxx, minn;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a;
    maxx = max(maxx, a);
    minn = min(minn, a);
  }
  cout << maxx - minn;
  return 0;
}
