a vector that store indices of the negative elements
List < int > neg = new List < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] > 0 ) pos . Add ( i ) ; else if ( arr [ i ] < 0 ) neg . Add ( i ) ; }