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