If freq of an element is greater than 0 update the value of arr [ ] at index cnt & increment cnt
if ( freq [ i ] > 0 ) { var value = 100000 - i ; arr [ cnt ] = 100000 * freq [ i ] + value ; cnt ++ ; } }