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