cswork / OAOpen practice workspace

AmazonOA #163

Find Maximum Number of Batches

Estimated HardJudge-ready

Topics (AI-labelled)GreedyBits & Math

Each category has a given quantity. Each batch contains at most 1 item of each category, batch sizes are strictly increasing, items cannot be reused, and leftovers are allowed. Find the maximum number of batches.

Input

The first line contains n, and the second line contains n quantities. This site sets 1≤n≤100000 and quantities in 0..10^9.

Output

Output a single integer answer.

Example 1

Input:

5
2 3 4 1 2

Output:

4

Example 2

Input:

1
100

Output:

1

Example 3

Input:

3
1 1 1

Output:

2

Example notes

Example 1: you can form four batches of sizes 1, 2, 3 and 4; a fifth batch would need 15 items cumulatively, but there are only 12. Example 2: there is only one category, so each batch has at most 1 item, giving at most 1 batch. Example 3: three items of different categories can be split into two batches of 1 and 2 items, so the answer is 2.

Editorial

Loading solution…