#include <stdio.h>
#include <stdlib.h>

int main()
{
    int N, K, i;
    scanf("%d", &N);
    scanf("%d", &K);
    int potions[N];
    for(i=0; i<N; i++) {
        scanf("%d", &potions[i]);
    }
    int min, max;
    min=potions[0];
    max=potions[0];
    for (i=0; i<N; i++) {
        if (potions[i]<min) {
            min = potions[i];
        }
        if (potions[i]>max) {
            max = potions[i];
        }
    }
    printf("%d", max-min);
    return 0;
}