#include int *pX = nullptr; int N = 0; int GetDiff ( int idx1 , int idx2 ); int main ( void ) { scanf ( "%d" , &N ); pX = new int [ N ]; int diff , diffbuf; for ( int i = 0; i < N; i++ ) { scanf ( "%d" , pX + i ); } for ( int i = 0; i < ( N - 1 ); i++ ) { if ( i == 0 ) { diff = GetDiff ( i , i + 1 ); } else { diffbuf = GetDiff ( i , i + 1 ); if ( diffbuf < diff ) diff = diffbuf; } } delete []pX; printf ( "%d\n" , diff ); return 0; } int GetDiff ( int idx1 , int idx2 ) { bool bEnableCurrent = false; int Current; if ( *( pX + idx1 ) != *( pX + idx2 ) ) { bEnableCurrent = true; Current = *( pX + idx1 ) - *( pX + idx2 ); if ( Current < 0 ) Current *= -1; } int diff= -1 , diffbuf; for ( int i = idx2 + 1; i < N; i++ ) { if ( i == ( idx2 + 1 ) ) { diff = GetDiff ( idx1 , i ); } else { diffbuf = GetDiff ( idx1 , i ); if ( diffbuf < diff ) diff = diffbuf; } } if ( bEnableCurrent ) { if (diff != -1 )return ( Current < diff ) ? Current : diff; return Current; } return diff; }