#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
for(int i=0;i<n-1;i++){
for(int j=i+1;j<n;j++){
if(a[i]>a[j]){
int temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
int x=a[n-1]-a[0];
cout<<x;
}
I2luY2x1ZGU8aW9zdHJlYW0+CiB1c2luZyBuYW1lc3BhY2Ugc3RkOwogaW50IG1haW4oKXsKIAlpbnQgbjsKIAljaW4+Pm47CiAJaW50IGFbbl07CiAJZm9yKGludCBpPTA7aTxuO2krKyl7CiAJCWNpbj4+YVtpXTsKCSB9CgkgZm9yKGludCBpPTA7aTxuLTE7aSsrKXsKCSAJZm9yKGludCBqPWkrMTtqPG47aisrKXsKCSAJCWlmKGFbaV0+YVtqXSl7CgkgCQkJaW50IHRlbXA9YVtpXTsKCSAJCQlhW2ldPWFbal07CgkgCQkJYVtqXT10ZW1wOwoJCQkgfQoJCSB9CgkgfQoJIGludCB4PWFbbi0xXS1hWzBdOwoJIGNvdXQ8PHg7CiB9