#include <bits/stdc++.h>
using namespace std;
void solve(long long N, std::vector<long long> a) {
  sort(a.begin(), a.end());
  cout << a[N - 1] - a[0] << '\n';
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N;
  scanf("%lld", &N);
  std::vector<long long> a(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &a[i]);
  }
  solve(N, std::move(a));
  return 0;
}
