#include<iostream>
using namespace std;

int main(){
  int n; cin >> n;
  int mn = INT_MAx , mx = INT_MIN;
 while(n--){
   int x; cin >> x;
   mn = min(x,mn) , mx = max(mx , x);
 }
  cout << mx - mn;
}