#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, mx = -1, mn = 1000000007;
  scanf("%lld", &n);
  long long ar[n];
  for (long long i = 0; i < n; i++) {
    scanf("%lld", &ar[i]);
    mx = max(mx, ar[i]);
    mn = min(mn, ar[i]);
  }
  long long ans = (mx - mn);
  printf("%lld\n", ans);
  return 0;
}
