#include <bits/stdc++.h>
int main() {
  int n, i, max, min, dis = 0;
  scanf("%d", &n);
  int a[n];
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  max = a[0];
  min = a[0];
  for (i = 0; i < n - 1; i++) {
    if (max < a[i]) max = a[i];
    if (min > a[i]) min = a[i];
  }
  dis = max - min;
  printf("%d\n", dis);
  return 0;
}
