Solution exists if GCD of array is equal to the minimum element of the array
if ( GCD_of_array == arr . get ( 0 ) ) { answer . add ( arr . get ( 0 ) ) ; for ( int i = 1 ; i < n ; i ++ ) { answer . add ( arr . get ( 0 ) ) ; answer . add ( arr . get ( i ) ) ; }