Frequency array to store freq of every element of the array
int i ; int [ ] A = new int [ 1000001 ] ; Array . Clear ( A , 0 , 1000001 ) ; for ( i = 0 ; i < n ; i ++ ) { A [ arr [ i ] ] ++ ; } int j = 0 ;