#include <bits/stdc++.h> // imports every library in c++
using namespace std; // ; is essential | says that you are USING the libraries

int N, max, min;
stack<int> A;
int main() {
    cin >> N;
    for ( int i=0; i<N; i++ ) {
        cin >> max;
        A.push(max);
    }
    max = 0;
    min = 0;
    for ( int i=0; i<N;  i++ ) {
        if (A.top() > max ) {
            max = A.top();
        }
        if (A.top() < min ) {
          min = A.top();
        }
      	A.pop();
    }
  cout << max - min << "\n";
}