#include <bits/stdc++.h>
int a[200000 + 1];
int main() {
  int n;
  std::cin >> n;
  long long int max = 0;
  long long int min = 1LL << 60;
  for (int i = 0; i < n; ++i) {
    std::cin >> a[i];
    max = std::max((long long int)a[i], max);
    min = std::min((long long int)a[i], min);
  }
  std::cout << max - min << std::endl;
  return 0;
}
