#include<bits/stdc++.h>
using namespace std;

int main()
{
  int n;
  cin>>n;
  int k; 
  set<int> s;
  int t = n;
  while(t--)
  {
    cin>>k;
    s.insert(k);
  }
  
 	int d = *(s.end()-1) - *s.begin();
  cout<<d<<endl;
    