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