#include int main(void){ int n; scanf( "%d", &n ); int i, j; int x; //int pos[n]; char pos[1000000]; int max = 0; long min = 1000001; int d = 0; int from = -1; for( i = 0; i <= 1000000; i++ ){ pos[i] = 'o'; } for( i = 0; i < n; i++ ){ scanf( "%d", &x ); pos[x] = 'x'; if( x > max ){ max = x; } } for( i = 0; i <= max; i++ ){ if( pos[i] == 'x' ){ if( from < 0 ){ from = i; }else{ d = i - from; if( d > 0 && d < min ){ min = d; } } } } printf( "%d\n", ( min == 1000001 ) ? 0 : min ); }