Store values according to the mentioned approach
for ( let i = 0 ; i < N ; ++ i ) { if ( v [ i ] [ 0 ] >= 0 ) { pos . push ( [ - v [ i ] [ 1 ] , v [ i ] [ 0 ] ] ) ; } else { neg . push ( [ v [ i ] [ 0 ] - v [ i ] [ 1 ] , - v [ i ] [ 0 ] ] ) ; } }