Loop to store all the positive elements in the map
for ( var i = 0 ; i < n ; i ++ ) { if ( arr [ i ] >= 0 && ! mp . has ( arr [ i ] ) ) mp . set ( arr [ i ] , 1 ) ; } var first = 0 ; var last = 0 ; var ans = 0 ; var INF = 1000000 ;