//Function to count the frequency of all elements from 1 to N in the array.
public static void frequencyCount(int arr, int N, int P)
//Decreasing all elements by 1 so that the elements
//become in range from 0 to n-1.
int maxi = Math.max(P,N);
int count = new int[maxi+1];
arr[i] = count[i+1];