#P1400E. Clear the Multiset
Clear the Multiset
No submission language available for this problem.
Description
You have a multiset containing several integers. Initially, it contains elements equal to , elements equal to , ..., elements equal to .
You may apply two types of operations:
- choose two integers and (), then remove one occurrence of , one occurrence of , ..., one occurrence of from the multiset. This operation can be applied only if each number from to occurs at least once in the multiset;
- choose two integers and (), then remove occurrences of from the multiset. This operation can be applied only if the multiset contains at least occurrences of .
What is the minimum number of operations required to delete all elements from the multiset?
The first line contains one integer ().
The second line contains integers , , ..., ().
Print one integer — the minimum number of operations required to delete all elements from the multiset.
Input
The first line contains one integer ().
The second line contains integers , , ..., ().
Output
Print one integer — the minimum number of operations required to delete all elements from the multiset.