Company: amazon_3march
Difficulty: medium
Minimum Number of Security Groups A financial services company has asked AWS for a private deployment of its cloud network. There are n servers in the network, and the i -th server needs security grade security[i] . The security team will place every server into exactly one security group , subject to two rules: All servers in a group must need the same security grade. The number of servers in any two groups must not differ by more than 1 . Rule 2 applies across the whole network, not just within one grade: if the smallest group holds c servers, then every group holds c or c + 1 servers. Find the minimum number of groups needed to place all n servers. Input Format The first line contains an integer n , the number of servers. Each of the next n lines contains one integer security[i] . Output Format Print a single integer — the minimum number of groups required. Constraints 1 <= n <= 10^5 1 <= security[i] <= 10^5 Examples Example 1 Input: 6 2 3 3 3 2 1 Output: 4 Explanation: