#include #include int sortfnc(const void *a,const void *b){ if(*(int*)a == *(int*)b){return 0;} if(*(int*)a < *(int*)b){return -1;} return 1; } int main(void){ int n,x[131072],i,min = 5000000; scanf("%d",&n); for(i = 0;i < n;i++){scanf("%d",&x[i]);} qsort(x,n,sizeof(int),sortfnc); if(n == 1){printf("0\n");return 0;} for(i = 0;i < n-1;i++){ if(x[i] != x[i+1] && min > x[i+1] - x[i]){min = x[i+1] - x[i];} } if(min == 5000000){printf("0\n");} else{printf("%d\n",min);} return 0; }