#include<bits\stdc++.h>
using namespace std;
int main(){
/*feropen("nihao.in","r",stdin);
feropen("nihao.out","w",stdout);*/
int a,m[10005],l=0;
cin>>a;
for(int i=1;i<=a;i++){
int u;
cin>>u;
m[u]=u;
}
for(int i=1;i<=10000;i++){
if(m[i]!=0){
int j=i+1;
while(m[j]==0){
j++;
}
if(j-i<l){
l=j;
}
}
}
cout<<l;
}