#include <bits/stdc++.h>
using namespace std;
int arr[200001];
int n;
int main() {
  int Min_ans = INT_MAX;
  int Max_ans = -Min_ans;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (int i = 0; i < n; i++) {
    Min_ans = min(Min_ans, arr[i]);
    Max_ans = max(Max_ans, arr[i]);
  }
  cout << (Max_ans - Min_ans) << endl;
  return 0;
}
