#C5767. Cutting the Warehouses

    ID: 49452 Type: Default 1000ms 256MiB

Cutting the Warehouses

Cutting the Warehouses

You are given M warehouses, each with an inventory quantity. In one operation, perform the following:

  1. Print the number of warehouses that currently have a strictly positive inventory.
  2. If no warehouse has a positive inventory, print 0 and terminate.
  3. Otherwise, find the smallest positive inventory value x among all warehouses.
  4. Subtract x from the inventory of every warehouse. Warehouses whose inventory becomes zero or negative are removed from further operations.

After performing these operations repeatedly, output 0 on a new line once all warehouses have been reduced to 0.

This problem is similar in spirit to the famous "Cut the Sticks" challenge.

inputFormat

The input is read from standard input. The first line contains a single integer M indicating the number of warehouses. The second line contains M space‐separated integers representing the inventory quantities of each warehouse.

outputFormat

For each operation, output a single integer on its own line representing the count of warehouses that have a strictly positive inventory before performing the subtraction. After all operations are completed (i.e. no warehouse remains with a positive inventory), output 0 on a new line.

## sample
5
7 8 3 4 6
5

4 3 2 1 0

</p>