#include<stdio.h>
#include<malloc.h>
#include<stdlib.h>
int Sort(const void* a, const void* b)
{
return *(int*)a-*(int*)b;
}
int main()
{
int n = 0, m = 0;
int* p = NULL;
scanf("%d", &n);
p = (int*)malloc(sizeof(int) * n);
if(p==NULL)
return 0;
for (int i = 0; i < n; i++)
{
scanf("%d", &m);
*(p + i) = m;
}
qsort(p, n, sizeof(int), Sort);
printf("%d\n", *(p + n - 1) - *(p));
free(p);
p=NULL;
return 0;
}