**Problem Link** : - [http://www.codechef.com/CODE2015/problems/RIT02]

**Author** :- [http://www.codechef.com/users/dvlpr_expert]

**Tester** :- [http://www.codechef.com/users/dvlpr_expert]

**Editorialist** :- [http://www.codechef.com/users/dvlpr_expert]

**DIFFICULTY** :- Medium

**PREREQUISITES** :- Maths,Array

**PROBLEM** :-

Poornima College is having N branches, where each branches have positive integral student. A minimize operation is performed on the branch such that all of them are reduced by the minimum number student in a branch.

Suppose we have 5 branches and all of them have below students in a branch.

5 2 4 2 6

Then in one minimize operation we reduce all the branch by 2 students. For next minimize operation 3 branch are left (have non-zero student), whose value are

3 2 4

Above step is repeated till no students are left in all branches.

Given students of N branches, print the number of student that are reduce in subsequent minimize operation.

**EXPLANATION** :-

We have to reduce a sequence of 5 numbers with the least value to be subtracted from all the 5 values. And this process of reduction is done till we get all the values reduced completely.

NOTE :- Here, You have to display the number of branches in which students are reduced.

**SOLUTION** :-

```
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
class Carry1 {
public static void main(String args[]) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = br.readLine();
int D = Integer.parseInt(line);
line = br.readLine();
LinkedList<Integer> list = new LinkedList<Integer>();
int n;
String p[] = line.split(" ");
for (int v = 0; v < D; v++) {
n = Integer.parseInt(p[v]);
list.add(n);
}
Collections.sort(list);
while (!list.isEmpty()) {
int x = list.get(0);
int size = list.size();
System.out.println(size);
for (int i = 0; i < list.size(); i++) {
int c1 = list.get(i);
if (c1 - x == 0) {
list.remove(i);
i--;
}
else
list.set(i, c1 - x);
}
}
}
private static void print(int i, int j) {
for (int q = 1; q <= i; q++)
System.out.print("5");
for (int q = 1; q <= j; q++)
System.out.print("3");
System.out.println();
}
}
```