#import <stdio.h>
#import <stdlib.h>

int compare_int(const void *a, const void *b) {
    return *(int*)a - *(int*)b;
}

int main(int argc, const char * argv[]) {
    int N;
    scanf("%d", &N);
    int *numbers = (int*)malloc(N * sizeof(int));
    
    int n;
    int i = 0;
    while (scanf("%d", &n) != EOF) {
        numbers[i] = n;
        i++;
    }
    
    qsort(numbers, N, sizeof(int), compare_int);
    
    printf("%d", numbers[N-1]-numbers[0]);
    
    free(numbers);
    return 0;
}
