#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, i, max, min;
  int arr[200000];
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> arr[i];
  }
  min = arr[0];
  max = arr[0];
  for (i = 0; i < n; i++) {
    if (arr[i] > max) {
      max = arr[i];
    }
    if (arr[i] < min) {
      min = arr[i];
    }
  }
  i = max - min;
  cout << i << endl;
  return 0;
}
