BFu Masters
Patrick is playing Boomerang Fu on the Nintendo Switch. Unfortunately, everyone else plays the game all the time. They know every trick, never miss, and have been putting Patrick in his place.
To give Patrick a chance, the group creates a special game mode with opponents. Opponent
is defeated after Patrick hits them
times.
Each boomerang throw can do the following:
- Hit one opponent on the way out.
- Hit one opponent on the way back.
The two hits from a single throw must target different opponents. Patrick may also use only one of the two hits. Each hit reduces the chosen opponent's remaining required hits by .
Assume Patrick can choose his targets perfectly. Find the minimum number of boomerang throws needed to defeat every opponent.
Input
The first line contains an integer (
), the number of opponents.
The second line contains integers
(
), where
is the number of times Patrick must hit opponent
.
Output
Output a single integer: the minimum number of boomerang throws needed to defeat every opponent.
Examples
Input 1
4
2 1 1 2
Output 1
3
Patrick can use the throws as follows:
- Hit opponents
and
.
- Hit opponents
and
.
- Hit opponents
and
.
This delivers all required hits in
throws.
Input 2
3
5 1 2
Output 2
5
Opponent needs
hits, but Patrick cannot hit the same opponent twice with one throw. Therefore, at least
throws are required. Patrick can achieve this by pairing three of those hits with the hits needed for the other opponents.
Comments