#include <bits/stdc++.h>
using namespace std;
constexpr int MOD = 1000000007;
using long long = long long;
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
void print(const std::vector<int> &v) {
  std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
  std::cout << std::endl;
}
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (long long i = 0; i < (long long)N; i++) {
    cin >> a[i];
  }
  cout << max(a.begin(), a.end()) - min(a.begin(), a.end()) << endl;
  return 0;
}
