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