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