#include <bits/stdc++.h>
int main() {
  int n, x;
  scanf("%d", &n);
  int max_x = 0, min_x = 10000000;
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    if (x > max_x) max_x = x;
    if (x < min_x) min_x = x;
  }
  int ans = max_x - min_x;
  printf("%d\n", ans);
  return 9;
}
