#include <bits/stdc++.h>
using namespace std;
string s;
int a, b, c, d;
char A, B;
priority_queue<int> pr;
vector<int> vec;
int main() {
  cin >> a;
  for (int i = 0; i < a; i++) {
    cin >> vec[i];
  }
  sort(vec.begin(), vec.end());
  cout << vec[a - 1] - vec[0] << endl;
}
