Function to find the max size possible
static int findMaxSize ( int [ ] a , int n ) { ArrayList frq = new ArrayList ( n + 1 ) ; for ( int i = 0 ; i <= n ; i ++ ) frq . Add ( 0 ) ; for ( int i = 0 ; i < n ; ++ i ) frq [ a [ i ] ] = ( int ) frq [ a [ i ] ] + 1 ;