#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int min = INT_MAX;
  int max = INT_MIN;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (a < min)
      min = a;
    else if (max < a)
      max = a;
  }
  cout << max - min << endl;
  return 0;
}
