#include <stdio.h>
int main() {
    int n = 0, i = 0, j = 0;
    int arr[500] = { 0 };
    int temp = 0;
    int Dis = 0;
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &arr[i]);
    }
    for (i = 0; i < n - 1; i++) {
        for (j = 0; j < n - 1 - i; j++) {
            if (arr[j] < arr[j + 1]) {
                temp = arr[j];
                arr[j] = arr[j + 1];
                arr[j + 1] = temp;
            }
        }
    }
    printf("%d\n", arr[0] - arr[n - 1]);
    return 0;
}