Maximum no. of groups of n and 2n in a given array