#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
  int N;
  cin >> N;
  
  vector<int>house(N,0);
  
  for(int i=0;i<N;i++){
    cin >> house[i];
  }
  
  sort(house.begin(),house,end());
  
  int ans = 0;
  int now_house = house[0];
  
  for(int i=1;i<N;i++){
    ans += house[i] - now_house;
    now_house = house[i];
  }
  
  cout << ans << endl;
  
  return 0;
}
