#include <bits/stdc++.h>
using namespace std;
int n,l=100000,h=0;
int A[100001];
int main() {
cin>>n;
for(int q=0;q<n;q=q+1){
cin>>A[q];
}
for(int q=n-1;q>=0;q=q-1){
if(A[q]<l){
l=A[q];
}
if(A[q]>h){
h=A[q];
}
}
cout<<h-l;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmludCBuLGw9MTAwMDAwLGg9MDsKaW50IEFbMTAwMDAxXTsKaW50IG1haW4oKSB7CgljaW4+Pm47Cglmb3IoaW50IHE9MDtxPG47cT1xKzEpewoJCWNpbj4+QVtxXTsKCX0KCWZvcihpbnQgcT1uLTE7cT49MDtxPXEtMSl7CgkJaWYoQVtxXTxsKXsKCQkJbD1BW3FdOwoJCX0KCQlpZihBW3FdPmgpewoJCQloPUFbcV07CgkJfQoJfQoJY291dDw8aC1sOwoJcmV0dXJuIDA7Cn0=