Created a 2D array to store minimum two multiple of any particular i .
List < int > [ ] mul = new List < int > [ mx + 1 ] ; for ( int i = 0 ; i < mul . Length ; i ++ ) mul [ i ] = new List < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( mul [ arr [ i ] ] . Count > 1 ) {