#include <bits/stdc++.h>
short N, i;
short a, min = 2048, max;
int main() {
  scanf("%hd", &N);
  for (i = 0; i < N; i++) {
    scanf("%hd", &a);
    if (a < min) {
      min = a;
    } else if (a > max) {
      max = a;
    }
  }
  printf("%d\n", max - min);
}
