#Lutece3347. Minecraft
Minecraft
Description
Scanffer is a student who enjoys playing Minecraft. As we all know, in Minecraft, players can obtain various types of logs, such as oak logs, spruce logs, jungle logs, etc. Each type of log corresponds to a specific type of plank, such as oak plank, spruce plank, jungle plank, etc.
In the crafting system of Minecraft, any planks can be crafted into sticks (the types of the planks can be different), and sticks and planks of the same type can be crafted into fences.
Now, assume there are types of planks in Minecraft, and Scanffer has planks of the -th type. Scanffer wants to craft the maximum number of fences using these wooden planks. Please output the maximum number of fences that can be crafted.
Input
The first line contains a single integer (), the number of plank types.
The second line contains integers (), where is the number of planks of the -th type that Scanffer has.
Output
Print a single integer: the maximum number of fences that can be crafted.
Samples
2
4 2
3
4
6 4 4 6
12
Note
In the first test case, Scanffer can use all the planks of the second type to craft into sticks. Then use the planks of the first type and two sticks to craft fences.
In the second test case, use planks of the first type and planks of the fourth type to craft into sticks. Then use all the rest of the planks to craft fences.
Resources
电子科技大学第十五届 ACM 趣味程序设计竞赛