Finding Forks
Time limit1sMemory limit1024 MB
Given the number of forks of each type left in the drawer, find the fewest forks that could have been in the dishwasher to leave two places empty.
- Level
Easy3 of 10
- Topics
- Sorting, Implementation
- Solved
- No attempts yet
Problem
Your cutlery drawer contains many types of forks. Each has its own purpose and its own place in the drawer. After a dinner party with all your friends, disaster struck! You put all the used forks in the dishwasher, but now you are unsure where to put back some of the forks, because at least two places in the cutlery drawer are empty! Worse, you do not remember which type of fork belongs where!
What is the minimum number of forks that must have been in the dishwasher to cause this confusion?
Input
The input consists of:
- One line with an integer (), the number of types of forks.
- One line with integers (), the number of forks of each type.
Output
Output the minimum number of forks that must have been in the dishwasher.